@dxos/react-ui-form 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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 +1134 -682
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +82 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1134 -682
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +84 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- 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 +63 -61
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +44 -16
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +75 -73
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +11 -5
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +8 -7
- 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 +6 -10
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts +4 -4
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts +8 -1
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +84 -0
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +15 -7
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectField.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 +63 -61
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TextField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TupleField.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 +26 -4
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +63 -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 +127 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.test.d.ts +2 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.test.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 +28 -33
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/Settings.stories.d.ts +64 -61
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +43 -0
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -0
- package/dist/types/src/components/Settings/SettingsItem.d.ts +16 -0
- package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -0
- package/dist/types/src/components/Settings/SettingsSelectField.d.ts +18 -0
- package/dist/types/src/components/Settings/SettingsSelectField.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 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +6 -6
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +67 -64
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +4 -4
- 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/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +63 -61
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field-type.d.ts +19 -0
- package/dist/types/src/util/field-type.d.ts.map +1 -0
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/properties.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 +42 -42
- package/src/components/FieldEditor/FieldEditor.stories.tsx +6 -8
- package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
- package/src/components/FieldEditor/FieldEditor.tsx +6 -6
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +29 -44
- package/src/components/Form/Form.tsx +101 -54
- package/src/components/Form/FormField.tsx +39 -19
- package/src/components/Form/FormFieldComponent.stories.tsx +4 -4
- package/src/components/Form/FormFieldComponent.tsx +11 -11
- package/src/components/Form/FormFieldSet.tsx +121 -104
- package/src/components/Form/fields/ArrayField.tsx +10 -9
- package/src/components/Form/fields/GeoPointField.tsx +8 -7
- package/src/components/Form/fields/MarkdownField.stories.tsx +206 -0
- package/src/components/Form/fields/MarkdownField.tsx +135 -45
- package/src/components/Form/fields/RefField.tsx +85 -45
- package/src/components/Form/fields/SelectField.tsx +1 -1
- package/src/components/Form/fields/SelectOptionField.stories.tsx +10 -8
- package/src/components/Form/fields/SelectOptionField.tsx +13 -13
- package/src/components/Form/fields/TextField.tsx +2 -2
- package/src/components/Form/fields/TupleField.tsx +1 -1
- package/src/components/ObjectForm/ObjectForm.tsx +114 -0
- package/src/components/ObjectForm/index.ts +5 -0
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +16 -18
- package/src/components/ObjectPicker/ObjectPicker.tsx +92 -65
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +362 -0
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +101 -0
- package/src/components/ObjectProperties/ObjectProperties.tsx +141 -0
- package/src/components/ObjectProperties/index.ts +5 -0
- package/src/components/Settings/AUDIT.md +52 -0
- package/src/components/Settings/Settings.stories.tsx +69 -21
- package/src/components/Settings/Settings.tsx +33 -187
- package/src/components/Settings/SettingsFieldSet.tsx +257 -0
- package/src/components/Settings/SettingsItem.tsx +58 -0
- package/src/components/Settings/SettingsSelectField.tsx +59 -0
- package/src/components/Settings/index.ts +2 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +21 -19
- package/src/components/ViewEditor/ViewEditor.test.tsx +2 -2
- package/src/components/ViewEditor/ViewEditor.tsx +87 -50
- package/src/components/index.ts +2 -0
- package/src/components/testing.tsx +23 -12
- package/src/hooks/useFormHandler.ts +42 -24
- package/src/hooks/useKeyHandler.tsx +7 -7
- package/src/index.ts +0 -4
- package/src/translations.ts +66 -63
- package/src/util/field-type.ts +60 -0
- package/src/util/index.ts +1 -1
- package/src/util/refs.ts +7 -3
- 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/dist/types/src/util/echo.d.ts +0 -6
- package/dist/types/src/util/echo.d.ts.map +0 -1
- package/src/components/Form/Form-old.stories.tsx +0 -314
- package/src/util/echo.ts +0 -25
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.3fbcb4aa9b",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -11,77 +11,77 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#translations": "./src/translations.ts"
|
|
16
|
+
},
|
|
14
17
|
"exports": {
|
|
15
18
|
".": {
|
|
16
19
|
"source": "./src/index.ts",
|
|
17
20
|
"types": "./dist/types/src/index.d.ts",
|
|
18
21
|
"browser": "./dist/lib/browser/index.mjs",
|
|
19
22
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./translations": {
|
|
25
|
+
"source": "./src/translations.ts",
|
|
26
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
27
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
28
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
20
29
|
}
|
|
21
30
|
},
|
|
22
31
|
"types": "dist/types/src/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
"*": {}
|
|
25
|
-
},
|
|
26
32
|
"files": [
|
|
27
33
|
"dist",
|
|
28
34
|
"src"
|
|
29
35
|
],
|
|
30
36
|
"dependencies": {
|
|
31
|
-
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
32
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
33
37
|
"@effect-atom/atom-react": "^0.5.0",
|
|
34
38
|
"@fluentui/react-tabster": "9.26.11",
|
|
35
39
|
"@radix-ui/react-context": "1.1.1",
|
|
36
40
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
37
|
-
"date-fns": "^3.
|
|
38
|
-
"jsonpath": "^1.1.1",
|
|
41
|
+
"date-fns": "^3.6.0",
|
|
39
42
|
"tabster": "^8.5.5",
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/echo
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/react-
|
|
50
|
-
"@dxos/react-
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/react-ui-
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/react-ui-
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/ui-
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/react-ui-components": "0.8.4-main.3eb6e50203",
|
|
61
|
-
"@dxos/debug": "0.8.4-main.3eb6e50203"
|
|
43
|
+
"@dxos/async": "0.8.4-main.3fbcb4aa9b",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.3fbcb4aa9b",
|
|
45
|
+
"@dxos/echo-atom": "0.8.4-main.3fbcb4aa9b",
|
|
46
|
+
"@dxos/echo-db": "0.8.4-main.3fbcb4aa9b",
|
|
47
|
+
"@dxos/echo-react": "0.8.4-main.3fbcb4aa9b",
|
|
48
|
+
"@dxos/effect": "0.8.4-main.3fbcb4aa9b",
|
|
49
|
+
"@dxos/invariant": "0.8.4-main.3fbcb4aa9b",
|
|
50
|
+
"@dxos/keys": "0.8.4-main.3fbcb4aa9b",
|
|
51
|
+
"@dxos/lit-ui": "0.8.4-main.3fbcb4aa9b",
|
|
52
|
+
"@dxos/react-ui-components": "0.8.4-main.3fbcb4aa9b",
|
|
53
|
+
"@dxos/react-client": "0.8.4-main.3fbcb4aa9b",
|
|
54
|
+
"@dxos/react-ui-editor": "0.8.4-main.3fbcb4aa9b",
|
|
55
|
+
"@dxos/react-ui-list": "0.8.4-main.3fbcb4aa9b",
|
|
56
|
+
"@dxos/log": "0.8.4-main.3fbcb4aa9b",
|
|
57
|
+
"@dxos/react-ui-pickers": "0.8.4-main.3fbcb4aa9b",
|
|
58
|
+
"@dxos/react-ui-search": "0.8.4-main.3fbcb4aa9b",
|
|
59
|
+
"@dxos/types": "0.8.4-main.3fbcb4aa9b",
|
|
60
|
+
"@dxos/util": "0.8.4-main.3fbcb4aa9b",
|
|
61
|
+
"@dxos/ui-editor": "0.8.4-main.3fbcb4aa9b",
|
|
62
|
+
"@dxos/schema": "0.8.4-main.3fbcb4aa9b"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@types/jsonpath": "^0.2.4",
|
|
65
65
|
"@types/react": "~19.2.7",
|
|
66
66
|
"@types/react-dom": "~19.2.3",
|
|
67
|
-
"effect": "3.
|
|
67
|
+
"effect": "3.20.0",
|
|
68
68
|
"fast-check": "^3.19.0",
|
|
69
69
|
"react": "~19.2.3",
|
|
70
70
|
"react-dom": "~19.2.3",
|
|
71
|
-
"vite": "
|
|
72
|
-
"@dxos/random": "0.8.4-main.
|
|
73
|
-
"@dxos/react-client": "0.8.4-main.
|
|
74
|
-
"@dxos/react-ui
|
|
75
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
76
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
77
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
71
|
+
"vite": "^8.0.10",
|
|
72
|
+
"@dxos/random": "0.8.4-main.3fbcb4aa9b",
|
|
73
|
+
"@dxos/react-client": "0.8.4-main.3fbcb4aa9b",
|
|
74
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
75
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.3fbcb4aa9b",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.3fbcb4aa9b",
|
|
77
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"effect": "3.
|
|
80
|
+
"effect": "3.20.0",
|
|
81
81
|
"react": "~19.2.3",
|
|
82
82
|
"react-dom": "~19.2.3",
|
|
83
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
84
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
84
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
|
|
85
85
|
},
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
@@ -8,26 +8,24 @@ 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
|
-
import { translations } from '
|
|
16
|
-
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout } from '../testing';
|
|
15
|
+
import { translations } from '#translations';
|
|
17
16
|
|
|
17
|
+
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout } from '../testing';
|
|
18
18
|
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
19
19
|
|
|
20
|
-
// Type definition for debug objects exposed to tests.
|
|
21
20
|
export type FieldEditorDebugObjects = {
|
|
22
21
|
props: FieldEditorProps;
|
|
23
22
|
projection: ProjectionModel;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
27
25
|
const useTestProjection = () => {
|
|
28
26
|
return useMemo(() => {
|
|
29
27
|
const schema = createEchoSchema(Example);
|
|
30
|
-
const view =
|
|
28
|
+
const view = ViewModel.make({
|
|
31
29
|
name: 'Test',
|
|
32
30
|
query: Query.select(Filter.type(Example)),
|
|
33
31
|
jsonSchema: schema.jsonSchema,
|
|
@@ -82,7 +80,7 @@ const meta = {
|
|
|
82
80
|
title: 'ui/react-ui-form/FieldEditor',
|
|
83
81
|
component: FieldEditor as any,
|
|
84
82
|
render: DefaultStory,
|
|
85
|
-
decorators: [withTheme()],
|
|
83
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
86
84
|
parameters: {
|
|
87
85
|
layout: 'fullscreen',
|
|
88
86
|
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,26 +4,26 @@
|
|
|
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,
|
|
17
16
|
getFormatSchema,
|
|
18
17
|
} from '@dxos/schema';
|
|
19
18
|
|
|
20
|
-
import { translationKey } from '
|
|
19
|
+
import { translationKey } from '#translations';
|
|
20
|
+
|
|
21
21
|
import { getFormProperties } from '../../util';
|
|
22
22
|
import { Form, type FormFieldMap, type FormRootProps, SelectField, SelectOptionField } from '../Form';
|
|
23
23
|
|
|
24
24
|
export type FieldEditorProps = {
|
|
25
25
|
projection: ProjectionModel;
|
|
26
|
-
field: FieldType;
|
|
26
|
+
field: View.FieldType;
|
|
27
27
|
registry?: SchemaRegistry.SchemaRegistry;
|
|
28
28
|
view?: Obj.Unknown;
|
|
29
29
|
onSave: () => void;
|
|
@@ -69,7 +69,7 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
69
69
|
{...props}
|
|
70
70
|
options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({
|
|
71
71
|
value,
|
|
72
|
-
label: t(`format
|
|
72
|
+
label: t(`format.${value}.label`),
|
|
73
73
|
}))}
|
|
74
74
|
/>
|
|
75
75
|
),
|
|
@@ -152,7 +152,7 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
152
152
|
const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(
|
|
153
153
|
(props) => {
|
|
154
154
|
if (view) {
|
|
155
|
-
Obj.
|
|
155
|
+
Obj.update(view, () => {
|
|
156
156
|
projection.setFieldProjection({ field, props });
|
|
157
157
|
});
|
|
158
158
|
} else {
|
|
@@ -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,24 @@ 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 { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
16
|
|
|
17
|
-
import { translations } from '
|
|
18
|
-
import { TestLayout } from '../testing';
|
|
17
|
+
import { translations } from '#translations';
|
|
19
18
|
|
|
19
|
+
import { TestLayout } from '../testing';
|
|
20
20
|
import { type ExcludeId, Form, type FormRootProps, omitId } from './Form';
|
|
21
21
|
|
|
22
22
|
const Organization = Schema.Struct({
|
|
23
23
|
name: Schema.String.pipe(Schema.minLength(1)).annotations({ title: 'Full name' }),
|
|
24
24
|
}).pipe(
|
|
25
25
|
Type.object({
|
|
26
|
-
typename: 'example.
|
|
26
|
+
typename: 'com.example.type.organization',
|
|
27
27
|
version: '0.1.0',
|
|
28
28
|
}),
|
|
29
29
|
);
|
|
@@ -43,11 +43,11 @@ const Person = Schema.Struct({
|
|
|
43
43
|
title: 'State',
|
|
44
44
|
description: 'State code',
|
|
45
45
|
}),
|
|
46
|
-
zip: Schema.Number,
|
|
46
|
+
zip: Schema.Number.annotations({ title: 'ZIP Code' }),
|
|
47
47
|
}).annotations({ title: 'Address' }),
|
|
48
48
|
),
|
|
49
|
-
employer: Schema.optional(
|
|
50
|
-
tags: Schema.optional(Schema.Array(
|
|
49
|
+
employer: Schema.optional(Ref.Ref(Organization).annotations({ title: 'Employer' })),
|
|
50
|
+
tags: Schema.optional(Schema.Array(Ref.Ref(Tag.Tag)).annotations({ title: 'Tags' })),
|
|
51
51
|
status: Schema.optional(Schema.Literal('active', 'inactive').annotations({ title: 'Status' })),
|
|
52
52
|
notes: Schema.optional(Format.Text.annotations({ title: 'Notes' })),
|
|
53
53
|
location: Schema.optional(Format.GeoPoint.annotations({ title: 'Location' })),
|
|
@@ -65,16 +65,16 @@ const Person = Schema.Struct({
|
|
|
65
65
|
),
|
|
66
66
|
}).pipe(
|
|
67
67
|
Type.object({
|
|
68
|
-
typename: 'dxos.
|
|
68
|
+
typename: 'org.dxos.type.person', // TODO(burdon): Change all types to /schema
|
|
69
69
|
version: '0.1.0',
|
|
70
70
|
}),
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
export interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
74
74
|
|
|
75
|
-
type
|
|
75
|
+
type DefaultStoryProps<T extends AnyProperties> = {
|
|
76
|
+
schema?: Schema.Schema<T>;
|
|
76
77
|
debug?: boolean;
|
|
77
|
-
schema: Schema.Schema<T>;
|
|
78
78
|
} & FormRootProps<T>;
|
|
79
79
|
|
|
80
80
|
const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
@@ -82,10 +82,10 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
82
82
|
schema,
|
|
83
83
|
values: valuesProp,
|
|
84
84
|
...props
|
|
85
|
-
}:
|
|
85
|
+
}: DefaultStoryProps<T>) => {
|
|
86
86
|
const [values, setValues] = useState<Partial<T>>(valuesProp ?? {});
|
|
87
|
-
const
|
|
88
|
-
const space =
|
|
87
|
+
const spaces = useSpaces();
|
|
88
|
+
const space = spaces[0];
|
|
89
89
|
|
|
90
90
|
const handleSave = useCallback<NonNullable<FormRootProps<T>['onSave']>>((values) => {
|
|
91
91
|
log.info('save', { values, meta });
|
|
@@ -97,13 +97,17 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
97
97
|
setValues(valuesProp ?? {});
|
|
98
98
|
}, []);
|
|
99
99
|
|
|
100
|
+
if (!space) {
|
|
101
|
+
return <Loading />;
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
return (
|
|
101
105
|
<Tooltip.Provider>
|
|
102
|
-
<TestLayout json={{ values, schema: schema
|
|
106
|
+
<TestLayout json={{ values, schema: schema?.ast }}>
|
|
103
107
|
<Form.Root
|
|
104
108
|
debug={debug}
|
|
105
109
|
schema={schema}
|
|
106
|
-
|
|
110
|
+
defaultValues={values}
|
|
107
111
|
db={space.db}
|
|
108
112
|
onSave={handleSave}
|
|
109
113
|
onCancel={handleCancel}
|
|
@@ -111,6 +115,7 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
111
115
|
>
|
|
112
116
|
<Form.Viewport>
|
|
113
117
|
<Form.Content>
|
|
118
|
+
<Form.Section label='Section' description='This is a section' />
|
|
114
119
|
<Form.FieldSet />
|
|
115
120
|
<Form.Actions />
|
|
116
121
|
</Form.Content>
|
|
@@ -125,26 +130,17 @@ const meta = {
|
|
|
125
130
|
title: 'ui/react-ui-form/Form',
|
|
126
131
|
component: Form.Root,
|
|
127
132
|
render: DefaultStory,
|
|
128
|
-
|
|
129
133
|
decorators: [
|
|
130
134
|
withTheme(),
|
|
131
|
-
withLayout({
|
|
132
|
-
layout: 'fullscreen',
|
|
133
|
-
}),
|
|
135
|
+
withLayout({ layout: 'fullscreen' }),
|
|
134
136
|
withClientProvider({
|
|
135
137
|
createIdentity: true,
|
|
136
138
|
createSpace: true,
|
|
137
139
|
types: [Tag.Tag, Organization, Person],
|
|
138
|
-
|
|
139
|
-
const space = client.spaces.default;
|
|
140
|
+
onCreateSpace: ({ space }) => {
|
|
140
141
|
[
|
|
141
|
-
Obj.make(
|
|
142
|
-
Obj.make(Organization, { name:
|
|
143
|
-
Obj.make(Organization, { name: 'Backed' }),
|
|
144
|
-
Obj.make(Organization, { name: 'BCV' }),
|
|
145
|
-
Tag.make({ label: 'Tag 1' }),
|
|
146
|
-
Tag.make({ label: 'Tag 2' }),
|
|
147
|
-
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}` })),
|
|
148
144
|
].map((obj) => space.db.add(obj));
|
|
149
145
|
},
|
|
150
146
|
}),
|
|
@@ -153,11 +149,11 @@ const meta = {
|
|
|
153
149
|
layout: 'fullscreen',
|
|
154
150
|
translations,
|
|
155
151
|
},
|
|
156
|
-
} satisfies Meta<
|
|
152
|
+
} satisfies Meta<DefaultStoryProps<any>>;
|
|
157
153
|
|
|
158
154
|
export default meta;
|
|
159
155
|
|
|
160
|
-
type Story<T extends AnyProperties> = StoryObj<
|
|
156
|
+
type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
|
|
161
157
|
|
|
162
158
|
const values: Partial<Person> = {
|
|
163
159
|
name: 'Alice',
|
|
@@ -190,16 +186,5 @@ export const Static: Story<ExcludeId<typeof Person>> = {
|
|
|
190
186
|
};
|
|
191
187
|
|
|
192
188
|
export const Empty: Story<ExcludeId<typeof Person>> = {
|
|
193
|
-
|
|
194
|
-
<TestLayout>
|
|
195
|
-
<Form.Root>
|
|
196
|
-
<Form.Viewport>
|
|
197
|
-
<Form.Content>
|
|
198
|
-
<Form.FieldSet />
|
|
199
|
-
<Form.Actions />
|
|
200
|
-
</Form.Content>
|
|
201
|
-
</Form.Viewport>
|
|
202
|
-
</Form.Root>
|
|
203
|
-
</TestLayout>
|
|
204
|
-
),
|
|
189
|
+
args: {},
|
|
205
190
|
};
|