@dxos/react-ui-form 0.8.4-main.d05673bc65 → 0.8.4-main.d9fc60f731
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/index.mjs +2008 -840
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +83 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +2008 -840
- 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 +85 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +64 -61
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +71 -17
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +148 -86
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +24 -8
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +26 -13
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +11 -9
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts +19 -0
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts +50 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts +119 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
- package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
- 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/DateField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts +13 -0
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +1 -0
- 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 +85 -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 +12 -6
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts +4 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +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 +64 -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 +1 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/index.d.ts +2 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +3 -0
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/meta-tags.d.ts +30 -0
- package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts +2 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +8 -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 +28 -6
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +64 -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 +128 -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/ObjectTree/ObjectTree.d.ts +9 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +87 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
- package/dist/types/src/components/ObjectTree/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 +65 -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 +9 -11
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +68 -66
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +13 -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 +64 -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 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/properties.d.ts +18 -1
- package/dist/types/src/util/properties.d.ts.map +1 -1
- package/dist/types/src/util/properties.test.d.ts +2 -0
- package/dist/types/src/util/properties.test.d.ts.map +1 -0
- 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 +48 -41
- package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -4
- package/src/components/FieldEditor/FieldEditor.test.tsx +4 -2
- package/src/components/FieldEditor/FieldEditor.tsx +23 -17
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +46 -65
- package/src/components/Form/Form.tsx +176 -60
- package/src/components/Form/FormField.tsx +107 -38
- package/src/components/Form/FormFieldComponent.tsx +77 -20
- package/src/components/Form/FormFieldSet.tsx +128 -78
- package/src/components/Form/FormTooltipsContext.ts +25 -0
- package/src/components/Form/Layout/FormLayout.stories.test.tsx +51 -0
- package/src/components/Form/Layout/FormLayout.stories.tsx +422 -0
- package/src/components/Form/Layout/FormLayout.test.ts +59 -0
- package/src/components/Form/Layout/FormLayout.tsx +251 -0
- package/src/components/Form/Layout/annotation.ts +38 -0
- package/src/components/Form/Layout/index.ts +7 -0
- package/src/components/Form/Layout/parser.test.ts +120 -0
- package/src/components/Form/Layout/parser.ts +167 -0
- package/src/components/Form/fields/ArrayField.tsx +64 -35
- package/src/components/Form/fields/DateField.tsx +101 -0
- package/src/components/Form/fields/GeoPointField.tsx +12 -8
- package/src/components/Form/fields/InlineRefField.tsx +146 -0
- 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 +83 -42
- package/src/components/Form/fields/SelectField.tsx +17 -5
- package/src/components/Form/fields/SelectOptionField.stories.tsx +8 -6
- package/src/components/Form/fields/SelectOptionField.tsx +14 -13
- package/src/components/Form/fields/TextAreaField.tsx +1 -1
- package/src/components/Form/fields/TextField.tsx +2 -2
- package/src/components/Form/fields/TupleField.tsx +3 -2
- package/src/components/Form/fields/index.ts +2 -0
- package/src/components/Form/index.ts +3 -0
- package/src/components/Form/meta-tags.test.ts +47 -0
- package/src/components/Form/meta-tags.ts +33 -0
- package/src/components/ObjectForm/ObjectForm.tsx +109 -0
- package/src/components/ObjectForm/index.ts +5 -0
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +13 -11
- package/src/components/ObjectPicker/ObjectPicker.tsx +93 -66
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +350 -0
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +111 -0
- package/src/components/ObjectProperties/ObjectProperties.tsx +144 -0
- package/src/components/ObjectProperties/index.ts +5 -0
- package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
- package/src/components/ObjectTree/ObjectTree.tsx +190 -0
- package/src/components/ObjectTree/index.ts +5 -0
- package/src/components/Settings/AUDIT.md +51 -0
- package/src/components/Settings/Settings.stories.tsx +69 -21
- package/src/components/Settings/Settings.tsx +32 -181
- 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 +45 -51
- package/src/components/ViewEditor/ViewEditor.test.tsx +11 -9
- package/src/components/ViewEditor/ViewEditor.tsx +45 -55
- package/src/components/index.ts +3 -0
- package/src/components/testing.tsx +19 -11
- package/src/hooks/useKeyHandler.tsx +7 -7
- package/src/index.ts +0 -4
- package/src/translations.ts +67 -63
- package/src/util/field-type.ts +60 -0
- package/src/util/index.ts +1 -0
- package/src/util/properties.test.ts +121 -0
- package/src/util/properties.ts +47 -4
- package/src/util/refs.ts +7 -3
- package/src/vite-env.d.ts +10 -0
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.d9fc60f731",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,78 +8,85 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
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
|
-
"@
|
|
32
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
37
|
+
"@codemirror/lang-xml": "^6.1.0",
|
|
33
38
|
"@effect-atom/atom-react": "^0.5.0",
|
|
34
39
|
"@fluentui/react-tabster": "9.26.11",
|
|
35
40
|
"@radix-ui/react-context": "1.1.1",
|
|
36
41
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
37
|
-
"date-fns": "^3.
|
|
42
|
+
"date-fns": "^3.6.0",
|
|
38
43
|
"tabster": "^8.5.5",
|
|
39
|
-
"@dxos/async": "0.8.4-main.
|
|
40
|
-
"@dxos/echo": "0.8.4-main.
|
|
41
|
-
"@dxos/echo-
|
|
42
|
-
"@dxos/echo
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/react-ui-
|
|
53
|
-
"@dxos/react-ui-
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/ui-
|
|
59
|
-
"@dxos/util": "0.8.4-main.
|
|
60
|
-
"@dxos/react-ui-list": "0.8.4-main.d05673bc65"
|
|
44
|
+
"@dxos/async": "0.8.4-main.d9fc60f731",
|
|
45
|
+
"@dxos/echo-db": "0.8.4-main.d9fc60f731",
|
|
46
|
+
"@dxos/echo-atom": "0.8.4-main.d9fc60f731",
|
|
47
|
+
"@dxos/echo": "0.8.4-main.d9fc60f731",
|
|
48
|
+
"@dxos/echo-protocol": "0.8.4-main.d9fc60f731",
|
|
49
|
+
"@dxos/echo-react": "0.8.4-main.d9fc60f731",
|
|
50
|
+
"@dxos/invariant": "0.8.4-main.d9fc60f731",
|
|
51
|
+
"@dxos/keys": "0.8.4-main.d9fc60f731",
|
|
52
|
+
"@dxos/effect": "0.8.4-main.d9fc60f731",
|
|
53
|
+
"@dxos/lit-ui": "0.8.4-main.d9fc60f731",
|
|
54
|
+
"@dxos/react-client": "0.8.4-main.d9fc60f731",
|
|
55
|
+
"@dxos/log": "0.8.4-main.d9fc60f731",
|
|
56
|
+
"@dxos/react-ui-components": "0.8.4-main.d9fc60f731",
|
|
57
|
+
"@dxos/react-ui-editor": "0.8.4-main.d9fc60f731",
|
|
58
|
+
"@dxos/react-ui-search": "0.8.4-main.d9fc60f731",
|
|
59
|
+
"@dxos/react-ui-list": "0.8.4-main.d9fc60f731",
|
|
60
|
+
"@dxos/schema": "0.8.4-main.d9fc60f731",
|
|
61
|
+
"@dxos/ui-editor": "0.8.4-main.d9fc60f731",
|
|
62
|
+
"@dxos/types": "0.8.4-main.d9fc60f731",
|
|
63
|
+
"@dxos/react-ui-pickers": "0.8.4-main.d9fc60f731",
|
|
64
|
+
"@dxos/util": "0.8.4-main.d9fc60f731"
|
|
61
65
|
},
|
|
62
66
|
"devDependencies": {
|
|
63
67
|
"@types/react": "~19.2.7",
|
|
64
68
|
"@types/react-dom": "~19.2.3",
|
|
65
|
-
"effect": "3.
|
|
69
|
+
"effect": "3.21.2",
|
|
66
70
|
"fast-check": "^3.19.0",
|
|
67
71
|
"react": "~19.2.3",
|
|
68
72
|
"react-dom": "~19.2.3",
|
|
69
|
-
"vite": "^
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/react-
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/ui-
|
|
73
|
+
"vite": "^8.0.14",
|
|
74
|
+
"@dxos/effect-proto": "0.8.4-main.d9fc60f731",
|
|
75
|
+
"@dxos/protocols": "0.8.4-main.d9fc60f731",
|
|
76
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
77
|
+
"@dxos/react-client": "0.8.4-main.d9fc60f731",
|
|
78
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
79
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.d9fc60f731",
|
|
80
|
+
"@dxos/storybook-utils": "0.8.4-main.d9fc60f731",
|
|
81
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731",
|
|
82
|
+
"@dxos/ui-types": "0.8.4-main.d9fc60f731"
|
|
76
83
|
},
|
|
77
84
|
"peerDependencies": {
|
|
78
|
-
"effect": "3.
|
|
85
|
+
"effect": "3.21.2",
|
|
79
86
|
"react": "~19.2.3",
|
|
80
87
|
"react-dom": "~19.2.3",
|
|
81
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
82
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
88
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731",
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731"
|
|
83
90
|
},
|
|
84
91
|
"publishConfig": {
|
|
85
92
|
"access": "public"
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React, { useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Filter, Query } from '@dxos/echo';
|
|
8
|
+
import { Filter, Query, Type } from '@dxos/echo';
|
|
9
9
|
import { createEchoSchema } from '@dxos/echo/testing';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
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
20
|
export type FieldEditorDebugObjects = {
|
|
@@ -24,7 +24,7 @@ export type FieldEditorDebugObjects = {
|
|
|
24
24
|
|
|
25
25
|
const useTestProjection = () => {
|
|
26
26
|
return useMemo(() => {
|
|
27
|
-
const schema = createEchoSchema(Example);
|
|
27
|
+
const schema = createEchoSchema(Type.getSchema(Example));
|
|
28
28
|
const view = ViewModel.make({
|
|
29
29
|
name: 'Test',
|
|
30
30
|
query: Query.select(Filter.type(Example)),
|
|
@@ -9,14 +9,16 @@ 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
|
|
|
16
15
|
const { Default } = composeStories(stories);
|
|
17
16
|
|
|
18
17
|
describe('FieldEditor', () => {
|
|
19
|
-
afterEach(() => {
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
// Flush pending React scheduler work before teardown to prevent
|
|
20
|
+
// "window is not defined" errors from setImmediate callbacks firing after happy-dom cleanup.
|
|
21
|
+
await act(async () => {});
|
|
20
22
|
cleanup();
|
|
21
23
|
});
|
|
22
24
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Obj, type
|
|
8
|
-
import {
|
|
7
|
+
import { Filter, Obj, type Registry, Type, type View } from '@dxos/echo';
|
|
8
|
+
import { 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';
|
|
@@ -16,14 +16,15 @@ import {
|
|
|
16
16
|
getFormatSchema,
|
|
17
17
|
} from '@dxos/schema';
|
|
18
18
|
|
|
19
|
-
import { translationKey } from '
|
|
19
|
+
import { translationKey } from '#translations';
|
|
20
|
+
|
|
20
21
|
import { getFormProperties } from '../../util';
|
|
21
22
|
import { Form, type FormFieldMap, type FormRootProps, SelectField, SelectOptionField } from '../Form';
|
|
22
23
|
|
|
23
24
|
export type FieldEditorProps = {
|
|
24
25
|
projection: ProjectionModel;
|
|
25
26
|
field: View.FieldType;
|
|
26
|
-
registry?:
|
|
27
|
+
registry?: Registry.Registry;
|
|
27
28
|
view?: Obj.Unknown;
|
|
28
29
|
onSave: () => void;
|
|
29
30
|
onCancel?: () => void;
|
|
@@ -37,24 +38,26 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
37
38
|
const [props, setProps] = useState<PropertyType>(projection.getFieldProjection(field.id).props);
|
|
38
39
|
useEffect(() => setProps(projection.getFieldProjection(field.id).props), [field, projection]);
|
|
39
40
|
|
|
40
|
-
const [schemas, setSchemas] = useState<
|
|
41
|
+
const [schemas, setSchemas] = useState<Type.Type[]>([]);
|
|
41
42
|
useAsyncEffect(async () => {
|
|
42
43
|
if (!registry) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
const subscription = registry
|
|
47
|
+
const subscription = registry
|
|
48
|
+
.query(Filter.type(Type.Type))
|
|
49
|
+
.subscribe((query) => setSchemas(query.results), { fire: true });
|
|
47
50
|
|
|
48
51
|
// TODO(dmaretskyi): This shouldn't be needed.
|
|
49
|
-
const schemas = await registry.query().run();
|
|
52
|
+
const schemas = await registry.query(Filter.type(Type.Type)).run();
|
|
50
53
|
setSchemas(schemas);
|
|
51
54
|
|
|
52
55
|
return () => subscription?.();
|
|
53
56
|
}, [registry]);
|
|
54
57
|
|
|
55
|
-
const [referenceSchema, setReferenceSchema] = useState<
|
|
58
|
+
const [referenceSchema, setReferenceSchema] = useState<Type.Type>();
|
|
56
59
|
useEffect(() => {
|
|
57
|
-
setReferenceSchema(schemas.find((schema) => schema
|
|
60
|
+
setReferenceSchema(schemas.find((schema) => Type.getTypename(schema) === props?.referenceSchema));
|
|
58
61
|
}, [schemas, props?.referenceSchema]);
|
|
59
62
|
|
|
60
63
|
// TODO(burdon): Need to wrap otherwise throws error:
|
|
@@ -68,16 +71,19 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
68
71
|
{...props}
|
|
69
72
|
options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({
|
|
70
73
|
value,
|
|
71
|
-
label: t(`format
|
|
74
|
+
label: t(`format.${value}.label`),
|
|
72
75
|
}))}
|
|
73
76
|
/>
|
|
74
77
|
),
|
|
75
78
|
['referenceSchema' satisfies keyof PropertyType]: (props) => (
|
|
76
79
|
<SelectField
|
|
77
80
|
{...props}
|
|
78
|
-
options={schemas
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
options={schemas
|
|
82
|
+
.map((schema) => Type.getTypename(schema))
|
|
83
|
+
.filter((typename): typename is string => typename != null)
|
|
84
|
+
.map((typename) => ({
|
|
85
|
+
value: typename,
|
|
86
|
+
}))}
|
|
81
87
|
/>
|
|
82
88
|
),
|
|
83
89
|
['referencePath' satisfies keyof PropertyType]: (props) => (
|
|
@@ -85,7 +91,7 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
85
91
|
{...props}
|
|
86
92
|
options={
|
|
87
93
|
referenceSchema
|
|
88
|
-
? getFormProperties(referenceSchema.ast)
|
|
94
|
+
? getFormProperties(Type.getSchema(referenceSchema).ast)
|
|
89
95
|
.sort((a, b) => a.name.toString().localeCompare(b.name.toString()))
|
|
90
96
|
.map((p) => ({ value: p.name.toString() }))
|
|
91
97
|
: []
|
|
@@ -111,8 +117,8 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
setReferenceSchema((prev) => {
|
|
114
|
-
if (_props.referenceSchema !== prev
|
|
115
|
-
const newSchema = schemas.find((schema) => schema
|
|
120
|
+
if (_props.referenceSchema !== (prev ? Type.getTypename(prev) : undefined)) {
|
|
121
|
+
const newSchema = schemas.find((schema) => Type.getTypename(schema) === _props.referenceSchema);
|
|
116
122
|
if (newSchema) {
|
|
117
123
|
return newSchema;
|
|
118
124
|
}
|
|
@@ -151,7 +157,7 @@ export const FieldEditor = ({ readonly, projection, field, registry, view, onSav
|
|
|
151
157
|
const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(
|
|
152
158
|
(props) => {
|
|
153
159
|
if (view) {
|
|
154
|
-
Obj.
|
|
160
|
+
Obj.update(view, () => {
|
|
155
161
|
projection.setFieldProjection({ field, props });
|
|
156
162
|
});
|
|
157
163
|
} 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,29 +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, Ref, Tag, Type } from '@dxos/echo';
|
|
9
|
+
import { DXN, 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
|
-
}).pipe(
|
|
25
|
-
Type.object({
|
|
26
|
-
typename: 'com.example.type.organization',
|
|
27
|
-
version: '0.1.0',
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
24
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
30
25
|
|
|
31
|
-
export
|
|
26
|
+
export type Organization = Type.InstanceType<typeof Organization>;
|
|
32
27
|
|
|
33
28
|
const Person = Schema.Struct({
|
|
34
29
|
name: Schema.String.pipe(Schema.minLength(1)).annotations({ title: 'Full name' }),
|
|
@@ -43,7 +38,7 @@ const Person = Schema.Struct({
|
|
|
43
38
|
title: 'State',
|
|
44
39
|
description: 'State code',
|
|
45
40
|
}),
|
|
46
|
-
zip: Schema.Number,
|
|
41
|
+
zip: Schema.Number.annotations({ title: 'ZIP Code' }),
|
|
47
42
|
}).annotations({ title: 'Address' }),
|
|
48
43
|
),
|
|
49
44
|
employer: Schema.optional(Ref.Ref(Organization).annotations({ title: 'Employer' })),
|
|
@@ -51,6 +46,9 @@ const Person = Schema.Struct({
|
|
|
51
46
|
status: Schema.optional(Schema.Literal('active', 'inactive').annotations({ title: 'Status' })),
|
|
52
47
|
notes: Schema.optional(Format.Text.annotations({ title: 'Notes' })),
|
|
53
48
|
location: Schema.optional(Format.GeoPoint.annotations({ title: 'Location' })),
|
|
49
|
+
birthday: Schema.optional(Format.DateOnly.annotations({ title: 'Birthday' })),
|
|
50
|
+
meetingAt: Schema.optional(Format.DateTime.annotations({ title: 'Next meeting' })),
|
|
51
|
+
reminderAt: Schema.optional(Format.TimeOnly.annotations({ title: 'Reminder time' })),
|
|
54
52
|
tasks: Schema.optional(Schema.Array(Schema.String).annotations({ title: 'Tasks' })),
|
|
55
53
|
locations: Schema.optional(Schema.Array(Format.GeoPoint).annotations({ title: 'Locations' })),
|
|
56
54
|
identities: Schema.optional(
|
|
@@ -63,30 +61,22 @@ const Person = Schema.Struct({
|
|
|
63
61
|
title: 'Identities',
|
|
64
62
|
}),
|
|
65
63
|
),
|
|
66
|
-
}).pipe(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
74
|
-
|
|
75
|
-
type StoryProps<T extends AnyProperties> = {
|
|
76
|
-
debug?: boolean;
|
|
77
|
-
schema: Schema.Schema<T>;
|
|
64
|
+
}).pipe(Type.makeObject(DXN.make('org.dxos.type.person', '0.1.0')));
|
|
65
|
+
|
|
66
|
+
export type Person = Type.InstanceType<typeof Person>;
|
|
67
|
+
|
|
68
|
+
type DefaultStoryProps<T extends AnyProperties> = {
|
|
69
|
+
schema?: Schema.Schema<T>;
|
|
78
70
|
} & FormRootProps<T>;
|
|
79
71
|
|
|
80
72
|
const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
81
|
-
debug,
|
|
82
73
|
schema,
|
|
83
74
|
values: valuesProp,
|
|
84
75
|
...props
|
|
85
|
-
}:
|
|
76
|
+
}: DefaultStoryProps<T>) => {
|
|
86
77
|
const [values, setValues] = useState<Partial<T>>(valuesProp ?? {});
|
|
87
|
-
const
|
|
88
|
-
const space =
|
|
89
|
-
|
|
78
|
+
const spaces = useSpaces();
|
|
79
|
+
const space = spaces[0];
|
|
90
80
|
const handleSave = useCallback<NonNullable<FormRootProps<T>['onSave']>>((values) => {
|
|
91
81
|
log.info('save', { values, meta });
|
|
92
82
|
setValues(values);
|
|
@@ -97,20 +87,24 @@ const DefaultStory = <T extends AnyProperties = AnyProperties>({
|
|
|
97
87
|
setValues(valuesProp ?? {});
|
|
98
88
|
}, []);
|
|
99
89
|
|
|
90
|
+
if (!space) {
|
|
91
|
+
return <Loading />;
|
|
92
|
+
}
|
|
93
|
+
|
|
100
94
|
return (
|
|
101
95
|
<Tooltip.Provider>
|
|
102
|
-
<TestLayout json={{ values, schema: schema
|
|
96
|
+
<TestLayout json={{ values, schema: schema?.ast }}>
|
|
103
97
|
<Form.Root
|
|
104
|
-
debug={debug}
|
|
105
98
|
schema={schema}
|
|
106
|
-
|
|
99
|
+
defaultValues={values}
|
|
107
100
|
db={space.db}
|
|
108
101
|
onSave={handleSave}
|
|
109
102
|
onCancel={handleCancel}
|
|
110
103
|
{...props}
|
|
111
104
|
>
|
|
112
|
-
<Form.Viewport>
|
|
105
|
+
<Form.Viewport scroll>
|
|
113
106
|
<Form.Content>
|
|
107
|
+
<Form.Section label='Section' description='This is a section' />
|
|
114
108
|
<Form.FieldSet />
|
|
115
109
|
<Form.Actions />
|
|
116
110
|
</Form.Content>
|
|
@@ -125,7 +119,6 @@ const meta = {
|
|
|
125
119
|
title: 'ui/react-ui-form/Form',
|
|
126
120
|
component: Form.Root,
|
|
127
121
|
render: DefaultStory,
|
|
128
|
-
|
|
129
122
|
decorators: [
|
|
130
123
|
withTheme(),
|
|
131
124
|
withLayout({ layout: 'fullscreen' }),
|
|
@@ -133,16 +126,10 @@ const meta = {
|
|
|
133
126
|
createIdentity: true,
|
|
134
127
|
createSpace: true,
|
|
135
128
|
types: [Tag.Tag, Organization, Person],
|
|
136
|
-
|
|
137
|
-
const space = client.spaces.default;
|
|
129
|
+
onCreateSpace: ({ space }) => {
|
|
138
130
|
[
|
|
139
|
-
Obj.make(
|
|
140
|
-
Obj.make(Organization, { name:
|
|
141
|
-
Obj.make(Organization, { name: 'Backed' }),
|
|
142
|
-
Obj.make(Organization, { name: 'BCV' }),
|
|
143
|
-
Tag.make({ label: 'Tag 1' }),
|
|
144
|
-
Tag.make({ label: 'Tag 2' }),
|
|
145
|
-
Tag.make({ label: 'Tag 3' }),
|
|
131
|
+
...Array.from({ length: 3 }).map((_, i) => Obj.make(Tag.Tag, { label: `Tag ${i}` })),
|
|
132
|
+
...Array.from({ length: 50 }).map((_, i) => Obj.make(Organization, { name: `Organization ${i}` })),
|
|
146
133
|
].map((obj) => space.db.add(obj));
|
|
147
134
|
},
|
|
148
135
|
}),
|
|
@@ -151,53 +138,47 @@ const meta = {
|
|
|
151
138
|
layout: 'fullscreen',
|
|
152
139
|
translations,
|
|
153
140
|
},
|
|
154
|
-
} satisfies Meta<
|
|
141
|
+
} satisfies Meta<DefaultStoryProps<any>>;
|
|
155
142
|
|
|
156
143
|
export default meta;
|
|
157
144
|
|
|
158
|
-
type Story<T extends AnyProperties> = StoryObj<
|
|
145
|
+
type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
|
|
146
|
+
|
|
147
|
+
const PersonSchema = Type.getSchema(Person);
|
|
159
148
|
|
|
160
149
|
const values: Partial<Person> = {
|
|
161
150
|
name: 'Alice',
|
|
162
151
|
location: [40.7128, -74.006],
|
|
163
152
|
tasks: ['task 1', 'task 2'],
|
|
153
|
+
birthday: '1990-05-12',
|
|
154
|
+
meetingAt: '2026-06-01T15:30:00.000Z',
|
|
155
|
+
reminderAt: '09:00:00',
|
|
164
156
|
};
|
|
165
157
|
|
|
166
|
-
export const Default: Story<ExcludeId<typeof
|
|
158
|
+
export const Default: Story<ExcludeId<typeof PersonSchema>> = {
|
|
167
159
|
args: {
|
|
168
|
-
schema: omitId(
|
|
160
|
+
schema: omitId(PersonSchema),
|
|
169
161
|
values,
|
|
170
162
|
autoSave: true,
|
|
171
163
|
},
|
|
172
164
|
};
|
|
173
165
|
|
|
174
|
-
export const Readonly: Story<ExcludeId<typeof
|
|
166
|
+
export const Readonly: Story<ExcludeId<typeof PersonSchema>> = {
|
|
175
167
|
args: {
|
|
176
|
-
schema: omitId(
|
|
168
|
+
schema: omitId(PersonSchema),
|
|
177
169
|
values,
|
|
178
170
|
readonly: true,
|
|
179
171
|
},
|
|
180
172
|
};
|
|
181
173
|
|
|
182
|
-
export const Static: Story<ExcludeId<typeof
|
|
174
|
+
export const Static: Story<ExcludeId<typeof PersonSchema>> = {
|
|
183
175
|
args: {
|
|
184
|
-
schema: omitId(
|
|
176
|
+
schema: omitId(PersonSchema),
|
|
185
177
|
values,
|
|
186
178
|
layout: 'static',
|
|
187
179
|
},
|
|
188
180
|
};
|
|
189
181
|
|
|
190
|
-
export const Empty: Story<ExcludeId<typeof
|
|
191
|
-
|
|
192
|
-
<TestLayout>
|
|
193
|
-
<Form.Root>
|
|
194
|
-
<Form.Viewport>
|
|
195
|
-
<Form.Content>
|
|
196
|
-
<Form.FieldSet />
|
|
197
|
-
<Form.Actions />
|
|
198
|
-
</Form.Content>
|
|
199
|
-
</Form.Viewport>
|
|
200
|
-
</Form.Root>
|
|
201
|
-
</TestLayout>
|
|
202
|
-
),
|
|
182
|
+
export const Empty: Story<ExcludeId<typeof PersonSchema>> = {
|
|
183
|
+
args: {},
|
|
203
184
|
};
|