@dxos/react-ui-form 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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/README.md +0 -1
- package/dist/lib/browser/index.mjs +1003 -668
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1003 -668
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +62 -61
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +23 -18
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +68 -67
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +7 -1
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +8 -6
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +62 -61
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +9 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/index.d.ts +2 -0
- package/dist/types/src/components/ObjectForm/index.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +10 -2
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +62 -61
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +9 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +83 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectProperties/index.d.ts +2 -0
- package/dist/types/src/components/ObjectProperties/index.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.d.ts +35 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts +82 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +2 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +66 -64
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts +2 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +62 -61
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/refs.d.ts +1 -0
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -38
- package/src/components/FieldEditor/FieldEditor.stories.tsx +7 -8
- package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
- package/src/components/FieldEditor/FieldEditor.tsx +3 -4
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +25 -26
- package/src/components/Form/Form.tsx +101 -66
- package/src/components/Form/FormField.tsx +32 -14
- package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
- package/src/components/Form/FormFieldComponent.tsx +17 -20
- package/src/components/Form/FormFieldSet.tsx +126 -105
- package/src/components/Form/fields/ArrayField.tsx +11 -8
- package/src/components/Form/fields/GeoPointField.tsx +6 -6
- package/src/components/Form/fields/MarkdownField.tsx +1 -1
- package/src/components/Form/fields/RefField.tsx +37 -20
- package/src/components/Form/fields/SelectField.tsx +1 -1
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -3
- package/src/components/Form/fields/SelectOptionField.tsx +9 -10
- package/src/components/Form/fields/TupleField.tsx +1 -1
- package/src/components/ObjectForm/ObjectForm.tsx +113 -0
- package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +13 -18
- package/src/components/ObjectPicker/ObjectPicker.tsx +71 -60
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +63 -0
- package/src/components/ObjectProperties/ObjectProperties.tsx +129 -0
- package/src/components/ObjectProperties/index.ts +5 -0
- package/src/components/Settings/Settings.stories.tsx +55 -0
- package/src/components/Settings/Settings.tsx +129 -0
- package/src/components/Settings/index.ts +5 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +36 -33
- package/src/components/ViewEditor/ViewEditor.test.tsx +3 -7
- package/src/components/ViewEditor/ViewEditor.tsx +117 -85
- package/src/components/index.ts +3 -1
- package/src/components/testing.tsx +20 -8
- package/src/hooks/useFormHandler.ts +42 -18
- package/src/hooks/useKeyHandler.tsx +7 -7
- package/src/translations.ts +63 -63
- package/src/util/refs.ts +7 -3
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -87
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/index.d.ts +0 -2
- package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
- package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
- package/src/components/Form/Form-old.stories.tsx +0 -314
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.9be5663bfe",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,58 +30,57 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
32
32
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
33
|
-
"@effect-atom/atom-react": "^0.
|
|
33
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
34
34
|
"@fluentui/react-tabster": "9.26.11",
|
|
35
35
|
"@radix-ui/react-context": "1.1.1",
|
|
36
36
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
37
|
-
"date-fns": "^3.
|
|
38
|
-
"jsonpath": "^1.1.1",
|
|
37
|
+
"date-fns": "^3.6.0",
|
|
39
38
|
"tabster": "^8.5.5",
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/echo": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/react-
|
|
51
|
-
"@dxos/react-
|
|
52
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
53
|
-
"@dxos/react
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/react-ui-
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
58
|
-
"@dxos/schema": "0.8.4-main.
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
39
|
+
"@dxos/debug": "0.8.4-main.9be5663bfe",
|
|
40
|
+
"@dxos/echo": "0.8.4-main.9be5663bfe",
|
|
41
|
+
"@dxos/app-toolkit": "0.8.4-main.9be5663bfe",
|
|
42
|
+
"@dxos/async": "0.8.4-main.9be5663bfe",
|
|
43
|
+
"@dxos/echo-query": "0.8.4-main.9be5663bfe",
|
|
44
|
+
"@dxos/effect": "0.8.4-main.9be5663bfe",
|
|
45
|
+
"@dxos/keys": "0.8.4-main.9be5663bfe",
|
|
46
|
+
"@dxos/invariant": "0.8.4-main.9be5663bfe",
|
|
47
|
+
"@dxos/lit-ui": "0.8.4-main.9be5663bfe",
|
|
48
|
+
"@dxos/log": "0.8.4-main.9be5663bfe",
|
|
49
|
+
"@dxos/react-ui-components": "0.8.4-main.9be5663bfe",
|
|
50
|
+
"@dxos/react-client": "0.8.4-main.9be5663bfe",
|
|
51
|
+
"@dxos/react-ui-editor": "0.8.4-main.9be5663bfe",
|
|
52
|
+
"@dxos/echo-react": "0.8.4-main.9be5663bfe",
|
|
53
|
+
"@dxos/react-ui-list": "0.8.4-main.9be5663bfe",
|
|
54
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.9be5663bfe",
|
|
55
|
+
"@dxos/react-ui-search": "0.8.4-main.9be5663bfe",
|
|
56
|
+
"@dxos/react-ui-stack": "0.8.4-main.9be5663bfe",
|
|
57
|
+
"@dxos/schema": "0.8.4-main.9be5663bfe",
|
|
58
|
+
"@dxos/react-ui-pickers": "0.8.4-main.9be5663bfe",
|
|
59
|
+
"@dxos/types": "0.8.4-main.9be5663bfe",
|
|
60
|
+
"@dxos/ui-types": "0.8.4-main.9be5663bfe",
|
|
61
|
+
"@dxos/util": "0.8.4-main.9be5663bfe"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@types/jsonpath": "^0.2.4",
|
|
65
64
|
"@types/react": "~19.2.7",
|
|
66
65
|
"@types/react-dom": "~19.2.3",
|
|
67
|
-
"effect": "3.
|
|
66
|
+
"effect": "3.20.0",
|
|
68
67
|
"fast-check": "^3.19.0",
|
|
69
68
|
"react": "~19.2.3",
|
|
70
69
|
"react-dom": "~19.2.3",
|
|
71
|
-
"vite": "7.1.
|
|
72
|
-
"@dxos/random": "0.8.4-main.
|
|
73
|
-
"@dxos/react-
|
|
74
|
-
"@dxos/react-ui
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
70
|
+
"vite": "^7.1.11",
|
|
71
|
+
"@dxos/random": "0.8.4-main.9be5663bfe",
|
|
72
|
+
"@dxos/react-client": "0.8.4-main.9be5663bfe",
|
|
73
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.9be5663bfe",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.9be5663bfe",
|
|
76
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
80
|
-
"effect": "3.
|
|
79
|
+
"effect": "3.20.0",
|
|
81
80
|
"react": "~19.2.3",
|
|
82
81
|
"react-dom": "~19.2.3",
|
|
83
|
-
"@dxos/ui
|
|
84
|
-
"@dxos/
|
|
82
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe",
|
|
83
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe"
|
|
85
84
|
},
|
|
86
85
|
"publishConfig": {
|
|
87
86
|
"access": "public"
|
|
@@ -8,26 +8,23 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
8
8
|
import { Filter, Query } from '@dxos/echo';
|
|
9
9
|
import { createEchoSchema } from '@dxos/echo/testing';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
|
-
import { ProjectionModel,
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback } from '@dxos/schema';
|
|
13
13
|
import { Example } from '@dxos/schema/testing';
|
|
14
14
|
|
|
15
15
|
import { translations } from '../../translations';
|
|
16
16
|
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout } from '../testing';
|
|
17
|
-
|
|
18
17
|
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
19
18
|
|
|
20
|
-
// Type definition for debug objects exposed to tests.
|
|
21
19
|
export type FieldEditorDebugObjects = {
|
|
22
20
|
props: FieldEditorProps;
|
|
23
21
|
projection: ProjectionModel;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
27
24
|
const useTestProjection = () => {
|
|
28
25
|
return useMemo(() => {
|
|
29
26
|
const schema = createEchoSchema(Example);
|
|
30
|
-
const view =
|
|
27
|
+
const view = ViewModel.make({
|
|
31
28
|
name: 'Test',
|
|
32
29
|
query: Query.select(Filter.type(Example)),
|
|
33
30
|
jsonSchema: schema.jsonSchema,
|
|
@@ -73,7 +70,9 @@ const DefaultStory = () => {
|
|
|
73
70
|
|
|
74
71
|
return (
|
|
75
72
|
<TestLayout json={json}>
|
|
76
|
-
<
|
|
73
|
+
<div role='none' className='col-span-full'>
|
|
74
|
+
<FieldEditor {...props} />
|
|
75
|
+
</div>
|
|
77
76
|
</TestLayout>
|
|
78
77
|
);
|
|
79
78
|
};
|
|
@@ -82,7 +81,7 @@ const meta = {
|
|
|
82
81
|
title: 'ui/react-ui-form/FieldEditor',
|
|
83
82
|
component: FieldEditor as any,
|
|
84
83
|
render: DefaultStory,
|
|
85
|
-
decorators: [withTheme],
|
|
84
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
86
85
|
parameters: {
|
|
87
86
|
layout: 'fullscreen',
|
|
88
87
|
translations,
|
|
@@ -9,7 +9,6 @@ import { afterEach, describe, expect, test } from 'vitest';
|
|
|
9
9
|
import { ProjectionModel } from '@dxos/schema';
|
|
10
10
|
|
|
11
11
|
import { FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
|
|
12
|
-
|
|
13
12
|
import * as stories from './FieldEditor.stories';
|
|
14
13
|
import { type FieldEditorDebugObjects } from './FieldEditor.stories';
|
|
15
14
|
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Obj, type SchemaRegistry } from '@dxos/echo';
|
|
7
|
+
import { Obj, type SchemaRegistry, type View } from '@dxos/echo';
|
|
8
8
|
import { type EchoSchema, Format, FormatEnums, formatToType } from '@dxos/echo/internal';
|
|
9
9
|
import { type SchemaProperty } from '@dxos/effect';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
import {
|
|
13
|
-
type FieldType,
|
|
14
13
|
type ProjectionModel,
|
|
15
14
|
type PropertyType,
|
|
16
15
|
formatToAdditionalPropertyAttributes,
|
|
@@ -23,7 +22,7 @@ import { Form, type FormFieldMap, type FormRootProps, SelectField, SelectOptionF
|
|
|
23
22
|
|
|
24
23
|
export type FieldEditorProps = {
|
|
25
24
|
projection: ProjectionModel;
|
|
26
|
-
field: FieldType;
|
|
25
|
+
field: View.FieldType;
|
|
27
26
|
registry?: SchemaRegistry.SchemaRegistry;
|
|
28
27
|
view?: Obj.Unknown;
|
|
29
28
|
onSave: () => void;
|
|
@@ -69,7 +68,7 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
69
68
|
{...props}
|
|
70
69
|
options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({
|
|
71
70
|
value,
|
|
72
|
-
label: t(`format
|
|
71
|
+
label: t(`format.${value}.label`),
|
|
73
72
|
}))}
|
|
74
73
|
/>
|
|
75
74
|
),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Form
|
|
2
|
+
|
|
3
|
+
## New features/polish
|
|
4
|
+
|
|
5
|
+
- [x] Unify readonly/inline modes.
|
|
6
|
+
- [x] Refs
|
|
7
|
+
- [x] Single-select (fix popover)
|
|
8
|
+
- [x] Multi-select (array)
|
|
9
|
+
- [ ] auto save doesn't work for combobox + select due to only firing on blur (workaround is to use onValuesChanged).
|
|
10
|
+
- [ ] Don't call save/autoSave if value hasn't changed.
|
|
11
|
+
- [ ] Fix onCancel (restore values).
|
|
12
|
+
- [ ] Fix useSchema Type.AnyObj cast.
|
|
13
|
+
- [ ] TableCellEditor (handleEnter/ModalController).
|
|
14
|
+
- [ ] Use FormFieldWrapper uniformly
|
|
15
|
+
- [ ] Inline tables.
|
|
16
|
+
- [ ] Defer query until popover.
|
|
17
|
+
- [ ] Omit id from sub properties (tune Omit)
|
|
@@ -6,24 +6,23 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import * as Schema from 'effect/Schema';
|
|
7
7
|
import React, { useCallback, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import { Annotation, Format, Obj, Tag, Type } from '@dxos/echo';
|
|
9
|
+
import { Annotation, Format, Obj, Ref, Tag, Type } from '@dxos/echo';
|
|
10
10
|
import { type AnyProperties } from '@dxos/echo/internal';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
12
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { Tooltip } from '@dxos/react-ui';
|
|
15
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
16
|
|
|
17
17
|
import { translations } from '../../translations';
|
|
18
18
|
import { TestLayout } from '../testing';
|
|
19
|
-
|
|
20
19
|
import { type ExcludeId, Form, type FormRootProps, omitId } from './Form';
|
|
21
20
|
|
|
22
21
|
const Organization = Schema.Struct({
|
|
23
22
|
name: Schema.String.pipe(Schema.minLength(1)).annotations({ title: 'Full name' }),
|
|
24
23
|
}).pipe(
|
|
25
24
|
Type.object({
|
|
26
|
-
typename: 'example.
|
|
25
|
+
typename: 'com.example.type.organization',
|
|
27
26
|
version: '0.1.0',
|
|
28
27
|
}),
|
|
29
28
|
);
|
|
@@ -43,11 +42,11 @@ const Person = Schema.Struct({
|
|
|
43
42
|
title: 'State',
|
|
44
43
|
description: 'State code',
|
|
45
44
|
}),
|
|
46
|
-
zip: Schema.Number,
|
|
45
|
+
zip: Schema.Number.annotations({ title: 'ZIP Code' }),
|
|
47
46
|
}).annotations({ title: 'Address' }),
|
|
48
47
|
),
|
|
49
|
-
employer: Schema.optional(
|
|
50
|
-
tags: Schema.optional(Schema.Array(
|
|
48
|
+
employer: Schema.optional(Ref.Ref(Organization).annotations({ title: 'Employer' })),
|
|
49
|
+
tags: Schema.optional(Schema.Array(Ref.Ref(Tag.Tag)).annotations({ title: 'Tags' })),
|
|
51
50
|
status: Schema.optional(Schema.Literal('active', 'inactive').annotations({ title: 'Status' })),
|
|
52
51
|
notes: Schema.optional(Format.Text.annotations({ title: 'Notes' })),
|
|
53
52
|
location: Schema.optional(Format.GeoPoint.annotations({ title: 'Location' })),
|
|
@@ -65,14 +64,14 @@ const Person = Schema.Struct({
|
|
|
65
64
|
),
|
|
66
65
|
}).pipe(
|
|
67
66
|
Type.object({
|
|
68
|
-
typename: 'dxos.
|
|
67
|
+
typename: 'org.dxos.type.person', // TODO(burdon): Change all types to /schema
|
|
69
68
|
version: '0.1.0',
|
|
70
69
|
}),
|
|
71
70
|
);
|
|
72
71
|
|
|
73
72
|
export interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
74
73
|
|
|
75
|
-
type
|
|
74
|
+
type DefaultStoryProps<T extends AnyProperties> = {
|
|
76
75
|
debug?: boolean;
|
|
77
76
|
schema: Schema.Schema<T>;
|
|
78
77
|
} & FormRootProps<T>;
|
|
@@ -82,10 +81,10 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
82
81
|
schema,
|
|
83
82
|
values: valuesProp,
|
|
84
83
|
...props
|
|
85
|
-
}:
|
|
84
|
+
}: DefaultStoryProps<T>) => {
|
|
86
85
|
const [values, setValues] = useState<Partial<T>>(valuesProp ?? {});
|
|
87
|
-
const
|
|
88
|
-
const space =
|
|
86
|
+
const spaces = useSpaces();
|
|
87
|
+
const space = spaces[0];
|
|
89
88
|
|
|
90
89
|
const handleSave = useCallback<NonNullable<FormRootProps<T>['onSave']>>((values) => {
|
|
91
90
|
log.info('save', { values, meta });
|
|
@@ -97,13 +96,17 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
97
96
|
setValues(valuesProp ?? {});
|
|
98
97
|
}, []);
|
|
99
98
|
|
|
99
|
+
if (!space) {
|
|
100
|
+
return <Loading />;
|
|
101
|
+
}
|
|
102
|
+
|
|
100
103
|
return (
|
|
101
104
|
<Tooltip.Provider>
|
|
102
105
|
<TestLayout json={{ values, schema: schema.ast }}>
|
|
103
106
|
<Form.Root
|
|
104
107
|
debug={debug}
|
|
105
108
|
schema={schema}
|
|
106
|
-
|
|
109
|
+
defaultValues={values}
|
|
107
110
|
db={space.db}
|
|
108
111
|
onSave={handleSave}
|
|
109
112
|
onCancel={handleCancel}
|
|
@@ -111,6 +114,7 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
111
114
|
>
|
|
112
115
|
<Form.Viewport>
|
|
113
116
|
<Form.Content>
|
|
117
|
+
<Form.Section label='Section' description='This is a section' />
|
|
114
118
|
<Form.FieldSet />
|
|
115
119
|
<Form.Actions />
|
|
116
120
|
</Form.Content>
|
|
@@ -127,21 +131,16 @@ const meta = {
|
|
|
127
131
|
render: DefaultStory,
|
|
128
132
|
|
|
129
133
|
decorators: [
|
|
130
|
-
withTheme,
|
|
134
|
+
withTheme(),
|
|
135
|
+
withLayout({ layout: 'fullscreen' }),
|
|
131
136
|
withClientProvider({
|
|
132
137
|
createIdentity: true,
|
|
133
138
|
createSpace: true,
|
|
134
139
|
types: [Tag.Tag, Organization, Person],
|
|
135
|
-
|
|
136
|
-
const space = client.spaces.default;
|
|
140
|
+
onCreateSpace: ({ space }) => {
|
|
137
141
|
[
|
|
138
|
-
Obj.make(
|
|
139
|
-
Obj.make(Organization, { name:
|
|
140
|
-
Obj.make(Organization, { name: 'Backed' }),
|
|
141
|
-
Obj.make(Organization, { name: 'BCV' }),
|
|
142
|
-
Tag.make({ label: 'Tag 1' }),
|
|
143
|
-
Tag.make({ label: 'Tag 2' }),
|
|
144
|
-
Tag.make({ label: 'Tag 3' }),
|
|
142
|
+
...Array.from({ length: 3 }).map((_, i) => Obj.make(Tag.Tag, { label: `Tag ${i}` })),
|
|
143
|
+
...Array.from({ length: 50 }).map((_, i) => Obj.make(Organization, { name: `Organization ${i}` })),
|
|
145
144
|
].map((obj) => space.db.add(obj));
|
|
146
145
|
},
|
|
147
146
|
}),
|
|
@@ -150,11 +149,11 @@ const meta = {
|
|
|
150
149
|
layout: 'fullscreen',
|
|
151
150
|
translations,
|
|
152
151
|
},
|
|
153
|
-
} satisfies Meta<
|
|
152
|
+
} satisfies Meta<DefaultStoryProps<any>>;
|
|
154
153
|
|
|
155
154
|
export default meta;
|
|
156
155
|
|
|
157
|
-
type Story<T extends AnyProperties> = StoryObj<
|
|
156
|
+
type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
|
|
158
157
|
|
|
159
158
|
const values: Partial<Person> = {
|
|
160
159
|
name: 'Alice',
|