@dxos/react-ui-form 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5
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 +2753 -2121
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +2753 -2121
- 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 +8 -8
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +83 -5
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +86 -25
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +129 -56
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +43 -0
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +77 -0
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +9 -0
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldSet.d.ts +18 -0
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts +18 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/BooleanField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts +5 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/NumberField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/RefField.d.ts +16 -0
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectField.d.ts +10 -0
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +5 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +83 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TextField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TupleField.d.ts +6 -0
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/index.d.ts +12 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/index.d.ts +2 -4
- package/dist/types/src/components/Form/index.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 +54 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +86 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
- 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 +43 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts +83 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +38 -0
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -0
- package/dist/types/src/components/Settings/SettingsItem.d.ts +17 -0
- package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +3 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +22 -10
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +85 -8
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -2
- 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/index.d.ts +2 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts +82 -0
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useKeyHandler.d.ts +7 -0
- package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +64 -55
- 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 +3 -3
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts +2 -2
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/properties.d.ts +7 -0
- package/dist/types/src/util/properties.d.ts.map +1 -0
- package/dist/types/src/util/refs.d.ts +3 -3
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -43
- package/src/components/FieldEditor/FieldEditor.stories.tsx +48 -31
- package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
- package/src/components/FieldEditor/FieldEditor.tsx +84 -90
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +144 -222
- package/src/components/Form/Form.tsx +359 -96
- package/src/components/Form/FormField.tsx +304 -0
- package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
- package/src/components/Form/FormFieldComponent.tsx +171 -0
- package/src/components/Form/FormFieldSet.tsx +144 -0
- package/src/components/Form/README.md +3 -0
- package/src/components/Form/fields/ArrayField.tsx +154 -0
- package/src/components/Form/fields/BooleanField.tsx +22 -0
- package/src/components/Form/fields/GeoPointField.tsx +120 -0
- package/src/components/Form/fields/MarkdownField.tsx +78 -0
- package/src/components/Form/fields/NumberField.tsx +39 -0
- package/src/components/Form/fields/RefField.tsx +198 -0
- package/src/components/Form/fields/SelectField.tsx +65 -0
- package/src/components/Form/fields/SelectOptionField.stories.tsx +65 -0
- package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +36 -31
- package/src/components/Form/fields/TextAreaField.tsx +38 -0
- package/src/components/Form/fields/TextField.tsx +38 -0
- package/src/components/Form/{custom/TupleInput.tsx → fields/TupleField.tsx} +17 -10
- package/src/components/Form/fields/index.ts +15 -0
- package/src/components/Form/index.ts +3 -4
- package/src/components/ObjectForm/ObjectForm.tsx +113 -0
- package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +209 -0
- package/src/components/ObjectPicker/ObjectPicker.tsx +186 -0
- package/src/components/ObjectPicker/index.ts +5 -0
- 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 +103 -0
- package/src/components/Settings/Settings.tsx +81 -0
- package/src/components/Settings/SettingsFieldSet.tsx +211 -0
- package/src/components/Settings/SettingsItem.tsx +62 -0
- package/src/components/Settings/index.ts +6 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +139 -63
- package/src/components/ViewEditor/ViewEditor.test.tsx +12 -15
- package/src/components/ViewEditor/ViewEditor.tsx +346 -211
- package/src/components/index.ts +4 -3
- package/src/components/testing.tsx +28 -12
- package/src/hooks/index.ts +2 -3
- package/src/hooks/useFormHandler.ts +380 -0
- package/src/hooks/useKeyHandler.tsx +37 -0
- package/src/translations.ts +67 -59
- package/src/util/field-type.ts +57 -0
- package/src/util/field.ts +33 -43
- package/src/util/formatting.ts +22 -22
- package/src/util/index.ts +2 -1
- package/src/util/properties.ts +18 -0
- package/src/util/refs.ts +17 -19
- 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 -8
- 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/ArrayField.d.ts +0 -16
- package/dist/types/src/components/Form/ArrayField.d.ts.map +0 -1
- package/dist/types/src/components/Form/Defaults.d.ts +0 -14
- package/dist/types/src/components/Form/Defaults.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormActions.d.ts +0 -9
- package/dist/types/src/components/Form/FormActions.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormContent.d.ts +0 -57
- package/dist/types/src/components/Form/FormContent.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormContext.d.ts +0 -23
- package/dist/types/src/components/Form/FormContext.d.ts.map +0 -1
- package/dist/types/src/components/Form/Input.d.ts +0 -26
- package/dist/types/src/components/Form/Input.d.ts.map +0 -1
- package/dist/types/src/components/Form/RefField.d.ts +0 -12
- package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +0 -4
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +0 -4
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +0 -7
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts +0 -6
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/index.d.ts +0 -4
- package/dist/types/src/components/Form/custom/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/factory.d.ts +0 -8
- package/dist/types/src/components/Form/factory.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/Form.d.ts +0 -15
- package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/index.d.ts +0 -2
- package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useForm.d.ts +0 -67
- package/dist/types/src/hooks/useForm.d.ts.map +0 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -23
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
- package/dist/types/src/util/schema.d.ts +0 -3
- package/dist/types/src/util/schema.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -42
- package/src/components/ControlSection/ControlSection.tsx +0 -139
- package/src/components/Form/ArrayField.tsx +0 -125
- package/src/components/Form/Defaults.tsx +0 -204
- package/src/components/Form/FormActions.tsx +0 -54
- package/src/components/Form/FormContent.tsx +0 -241
- package/src/components/Form/FormContext.tsx +0 -110
- package/src/components/Form/Input.tsx +0 -51
- package/src/components/Form/RefField.tsx +0 -214
- package/src/components/Form/custom/GeoPointInput.tsx +0 -72
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +0 -62
- package/src/components/Form/custom/index.ts +0 -7
- package/src/components/Form/factory.tsx +0 -31
- package/src/components/deprecated/Form.stories.tsx +0 -63
- package/src/components/deprecated/Form.tsx +0 -119
- package/src/components/deprecated/FormInput.tsx +0 -71
- package/src/components/deprecated/index.ts +0 -5
- package/src/hooks/useForm.ts +0 -293
- package/src/hooks/useQueryRefOptions.ts +0 -53
- package/src/hooks/useRefQueryLookupHandler.ts +0 -39
- package/src/util/schema.ts +0 -14
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcfe5033a5",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"type": "module",
|
|
@@ -24,54 +28,52 @@
|
|
|
24
28
|
"src"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@atlaskit/pragmatic-drag-and-drop": "
|
|
28
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "
|
|
29
|
-
"@
|
|
31
|
+
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
32
|
+
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
33
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
34
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
30
35
|
"@radix-ui/react-context": "1.1.1",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/echo
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/keys": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/schema": "0.8.4-main.f5c0578",
|
|
51
|
-
"@dxos/util": "0.8.4-main.f5c0578"
|
|
36
|
+
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
37
|
+
"date-fns": "^3.6.0",
|
|
38
|
+
"tabster": "^8.5.5",
|
|
39
|
+
"@dxos/async": "0.8.4-main.fcfe5033a5",
|
|
40
|
+
"@dxos/echo-react": "0.8.4-main.fcfe5033a5",
|
|
41
|
+
"@dxos/effect": "0.8.4-main.fcfe5033a5",
|
|
42
|
+
"@dxos/echo": "0.8.4-main.fcfe5033a5",
|
|
43
|
+
"@dxos/invariant": "0.8.4-main.fcfe5033a5",
|
|
44
|
+
"@dxos/log": "0.8.4-main.fcfe5033a5",
|
|
45
|
+
"@dxos/keys": "0.8.4-main.fcfe5033a5",
|
|
46
|
+
"@dxos/react-client": "0.8.4-main.fcfe5033a5",
|
|
47
|
+
"@dxos/react-ui-components": "0.8.4-main.fcfe5033a5",
|
|
48
|
+
"@dxos/react-ui-list": "0.8.4-main.fcfe5033a5",
|
|
49
|
+
"@dxos/react-ui-pickers": "0.8.4-main.fcfe5033a5",
|
|
50
|
+
"@dxos/react-ui-search": "0.8.4-main.fcfe5033a5",
|
|
51
|
+
"@dxos/schema": "0.8.4-main.fcfe5033a5",
|
|
52
|
+
"@dxos/types": "0.8.4-main.fcfe5033a5",
|
|
53
|
+
"@dxos/util": "0.8.4-main.fcfe5033a5",
|
|
54
|
+
"@dxos/lit-ui": "0.8.4-main.fcfe5033a5"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
|
-
"@types/
|
|
55
|
-
"@types/react": "~
|
|
56
|
-
"
|
|
57
|
-
"effect": "3.17.7",
|
|
57
|
+
"@types/react": "~19.2.7",
|
|
58
|
+
"@types/react-dom": "~19.2.3",
|
|
59
|
+
"effect": "3.20.0",
|
|
58
60
|
"fast-check": "^3.19.0",
|
|
59
|
-
"react": "~
|
|
60
|
-
"react-dom": "~
|
|
61
|
-
"vite": "
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/react-
|
|
64
|
-
"@dxos/react-ui
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
61
|
+
"react": "~19.2.3",
|
|
62
|
+
"react-dom": "~19.2.3",
|
|
63
|
+
"vite": "^7.1.11",
|
|
64
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
65
|
+
"@dxos/react-client": "0.8.4-main.fcfe5033a5",
|
|
66
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
67
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
|
|
68
|
+
"@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
|
|
69
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
68
70
|
},
|
|
69
71
|
"peerDependencies": {
|
|
70
|
-
"effect": "
|
|
71
|
-
"react": "~
|
|
72
|
-
"react-dom": "~
|
|
73
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
74
|
-
"@dxos/
|
|
72
|
+
"effect": "3.20.0",
|
|
73
|
+
"react": "~19.2.3",
|
|
74
|
+
"react-dom": "~19.2.3",
|
|
75
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
76
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
75
77
|
},
|
|
76
78
|
"publishConfig": {
|
|
77
79
|
"access": "public"
|
|
@@ -2,33 +2,54 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useMemo } from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { Filter, Query } from '@dxos/echo';
|
|
9
|
+
import { createEchoSchema } from '@dxos/echo/testing';
|
|
11
10
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { ProjectionModel, ViewModel, createEchoChangeCallback } from '@dxos/schema';
|
|
13
|
+
import { Example } from '@dxos/schema/testing';
|
|
15
14
|
|
|
16
15
|
import { translations } from '../../translations';
|
|
17
|
-
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout
|
|
18
|
-
|
|
16
|
+
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout } from '../testing';
|
|
19
17
|
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
20
18
|
|
|
21
|
-
// Type definition for debug objects exposed to tests.
|
|
22
19
|
export type FieldEditorDebugObjects = {
|
|
23
20
|
props: FieldEditorProps;
|
|
24
21
|
projection: ProjectionModel;
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
const useTestProjection = () => {
|
|
25
|
+
return useMemo(() => {
|
|
26
|
+
const schema = createEchoSchema(Example);
|
|
27
|
+
const view = ViewModel.make({
|
|
28
|
+
name: 'Test',
|
|
29
|
+
query: Query.select(Filter.type(Example)),
|
|
30
|
+
jsonSchema: schema.jsonSchema,
|
|
31
|
+
});
|
|
32
|
+
const projection = new ProjectionModel({
|
|
33
|
+
view,
|
|
34
|
+
baseSchema: schema.jsonSchema,
|
|
35
|
+
change: createEchoChangeCallback(view, schema),
|
|
36
|
+
});
|
|
37
|
+
projection.normalizeView();
|
|
38
|
+
return { view, projection };
|
|
39
|
+
}, []);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const DefaultStory = () => {
|
|
43
|
+
const { view, projection } = useTestProjection();
|
|
28
44
|
|
|
29
|
-
const DefaultStory = (props: FieldEditorProps) => {
|
|
30
45
|
const handleComplete: FieldEditorProps['onSave'] = () => {
|
|
31
|
-
log.info('onClose'
|
|
46
|
+
log.info('onClose');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const props: FieldEditorProps = {
|
|
50
|
+
projection,
|
|
51
|
+
field: view.projection.fields[0],
|
|
52
|
+
onSave: handleComplete,
|
|
32
53
|
};
|
|
33
54
|
|
|
34
55
|
// Expose objects on window for test access.
|
|
@@ -36,44 +57,40 @@ const DefaultStory = (props: FieldEditorProps) => {
|
|
|
36
57
|
if (typeof window !== 'undefined') {
|
|
37
58
|
(window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
|
|
38
59
|
props,
|
|
39
|
-
projection
|
|
60
|
+
projection,
|
|
40
61
|
} satisfies FieldEditorDebugObjects;
|
|
41
62
|
}
|
|
42
|
-
}, [props,
|
|
63
|
+
}, [props, projection]);
|
|
43
64
|
|
|
44
65
|
// NOTE(ZaymonFC): This looks awkward but it resolves an infinite parsing issue with sb.
|
|
45
66
|
const json = useMemo(
|
|
46
|
-
() => JSON.parse(JSON.stringify({ props, projection
|
|
47
|
-
[JSON.stringify(props), JSON.stringify(
|
|
67
|
+
() => JSON.parse(JSON.stringify({ props, projection })),
|
|
68
|
+
[JSON.stringify(props), JSON.stringify(projection)],
|
|
48
69
|
);
|
|
49
70
|
|
|
50
71
|
return (
|
|
51
72
|
<TestLayout json={json}>
|
|
52
|
-
<
|
|
53
|
-
<FieldEditor {...props} onSave={handleComplete} />
|
|
54
|
-
</TestPanel>
|
|
73
|
+
<FieldEditor {...props} />
|
|
55
74
|
</TestLayout>
|
|
56
75
|
);
|
|
57
76
|
};
|
|
58
77
|
|
|
59
|
-
const meta
|
|
78
|
+
const meta = {
|
|
60
79
|
title: 'ui/react-ui-form/FieldEditor',
|
|
61
|
-
component: FieldEditor,
|
|
80
|
+
component: FieldEditor as any,
|
|
62
81
|
render: DefaultStory,
|
|
63
|
-
decorators: [withLayout({
|
|
82
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
64
83
|
parameters: {
|
|
84
|
+
layout: 'fullscreen',
|
|
65
85
|
translations,
|
|
86
|
+
controls: {
|
|
87
|
+
disabled: true,
|
|
88
|
+
},
|
|
66
89
|
},
|
|
67
|
-
}
|
|
90
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
68
91
|
|
|
69
92
|
export default meta;
|
|
70
93
|
|
|
71
|
-
type Story = StoryObj<
|
|
94
|
+
type Story = StoryObj<typeof meta>;
|
|
72
95
|
|
|
73
|
-
export const Default: Story = {
|
|
74
|
-
args: {
|
|
75
|
-
projection: new ProjectionModel(createEchoSchema(TestSchema).jsonSchema, testView.projection),
|
|
76
|
-
field: testView.projection.fields[0],
|
|
77
|
-
},
|
|
78
|
-
parameters: { controls: { disabled: true } },
|
|
79
|
-
};
|
|
96
|
+
export const Default: Story = {};
|
|
@@ -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,50 +4,41 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SchemaRegistry } from '@dxos/echo
|
|
8
|
-
import { type EchoSchema,
|
|
7
|
+
import { Obj, type SchemaRegistry, type View } from '@dxos/echo';
|
|
8
|
+
import { type EchoSchema, Format, FormatEnums, formatToType } from '@dxos/echo/internal';
|
|
9
|
+
import { type SchemaProperty } from '@dxos/effect';
|
|
9
10
|
import { log } from '@dxos/log';
|
|
10
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
11
12
|
import {
|
|
12
|
-
type FieldType,
|
|
13
13
|
type ProjectionModel,
|
|
14
14
|
type PropertyType,
|
|
15
|
-
|
|
15
|
+
formatToAdditionalPropertyAttributes,
|
|
16
16
|
getFormatSchema,
|
|
17
|
-
getSchemaProperties,
|
|
18
|
-
sortProperties,
|
|
19
17
|
} from '@dxos/schema';
|
|
20
18
|
|
|
21
19
|
import { translationKey } from '../../translations';
|
|
22
|
-
import {
|
|
20
|
+
import { getFormProperties } from '../../util';
|
|
21
|
+
import { Form, type FormFieldMap, type FormRootProps, SelectField, SelectOptionField } from '../Form';
|
|
23
22
|
|
|
24
23
|
export type FieldEditorProps = {
|
|
25
|
-
readonly?: boolean;
|
|
26
24
|
projection: ProjectionModel;
|
|
27
|
-
field: FieldType;
|
|
28
|
-
registry?: SchemaRegistry;
|
|
25
|
+
field: View.FieldType;
|
|
26
|
+
registry?: SchemaRegistry.SchemaRegistry;
|
|
27
|
+
view?: Obj.Unknown;
|
|
29
28
|
onSave: () => void;
|
|
30
29
|
onCancel?: () => void;
|
|
31
|
-
} & Pick<
|
|
30
|
+
} & Pick<FormRootProps<any>, 'readonly'>;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* Displays a Form representing the metadata for a given `Field` and `View`.
|
|
35
34
|
*/
|
|
36
|
-
export const FieldEditor = ({
|
|
37
|
-
readonly,
|
|
38
|
-
projection,
|
|
39
|
-
field,
|
|
40
|
-
registry,
|
|
41
|
-
onSave,
|
|
42
|
-
onCancel,
|
|
43
|
-
outerSpacing,
|
|
44
|
-
}: FieldEditorProps) => {
|
|
35
|
+
export const FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }: FieldEditorProps) => {
|
|
45
36
|
const { t } = useTranslation(translationKey);
|
|
46
37
|
const [props, setProps] = useState<PropertyType>(projection.getFieldProjection(field.id).props);
|
|
47
38
|
useEffect(() => setProps(projection.getFieldProjection(field.id).props), [field, projection]);
|
|
48
39
|
|
|
49
40
|
const [schemas, setSchemas] = useState<EchoSchema[]>([]);
|
|
50
|
-
|
|
41
|
+
useAsyncEffect(async () => {
|
|
51
42
|
if (!registry) {
|
|
52
43
|
return;
|
|
53
44
|
}
|
|
@@ -55,14 +46,10 @@ export const FieldEditor = ({
|
|
|
55
46
|
const subscription = registry.query().subscribe((query) => setSchemas(query.results), { fire: true });
|
|
56
47
|
|
|
57
48
|
// TODO(dmaretskyi): This shouldn't be needed.
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return () => {
|
|
63
|
-
clearTimeout(t);
|
|
64
|
-
subscription?.();
|
|
65
|
-
};
|
|
49
|
+
const schemas = await registry.query().run();
|
|
50
|
+
setSchemas(schemas);
|
|
51
|
+
|
|
52
|
+
return () => subscription?.();
|
|
66
53
|
}, [registry]);
|
|
67
54
|
|
|
68
55
|
const [referenceSchema, setReferenceSchema] = useState<EchoSchema>();
|
|
@@ -74,11 +61,47 @@ export const FieldEditor = ({
|
|
|
74
61
|
// Class constructor SchemaClass cannot be invoked without 'new'.
|
|
75
62
|
const [{ fieldSchema }, setFieldSchema] = useState({ fieldSchema: getFormatSchema(props?.format) });
|
|
76
63
|
|
|
77
|
-
const
|
|
64
|
+
const fieldMap = useMemo<FormFieldMap>(
|
|
65
|
+
() => ({
|
|
66
|
+
['format' satisfies keyof PropertyType]: (props) => (
|
|
67
|
+
<SelectField
|
|
68
|
+
{...props}
|
|
69
|
+
options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({
|
|
70
|
+
value,
|
|
71
|
+
label: t(`format.${value}.label`),
|
|
72
|
+
}))}
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
['referenceSchema' satisfies keyof PropertyType]: (props) => (
|
|
76
|
+
<SelectField
|
|
77
|
+
{...props}
|
|
78
|
+
options={schemas.map((schema) => ({
|
|
79
|
+
value: schema.typename,
|
|
80
|
+
}))}
|
|
81
|
+
/>
|
|
82
|
+
),
|
|
83
|
+
['referencePath' satisfies keyof PropertyType]: (props) => (
|
|
84
|
+
<SelectField
|
|
85
|
+
{...props}
|
|
86
|
+
options={
|
|
87
|
+
referenceSchema
|
|
88
|
+
? getFormProperties(referenceSchema.ast)
|
|
89
|
+
.sort((a, b) => a.name.toString().localeCompare(b.name.toString()))
|
|
90
|
+
.map((p) => ({ value: p.name.toString() }))
|
|
91
|
+
: []
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
),
|
|
95
|
+
['options' satisfies keyof PropertyType]: (props) => <SelectOptionField {...props} />,
|
|
96
|
+
}),
|
|
97
|
+
[t, schemas, referenceSchema],
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const propIsNotType = useCallback((props: SchemaProperty[]) => props.filter((prop) => prop.name !== 'type'), []);
|
|
101
|
+
|
|
102
|
+
const handleValuesChanged = useCallback<NonNullable<FormRootProps<PropertyType>['onValuesChanged']>>(
|
|
78
103
|
(_props) => {
|
|
79
|
-
// TODO(
|
|
80
|
-
// TODO(Zaymon): Workout why old and new format values are the same sometimes even when
|
|
81
|
-
// selecting novel format values.
|
|
104
|
+
// TODO(Zaymon): Workout why old and new format values are the same sometimes even when selecting novel format values.
|
|
82
105
|
setFieldSchema((prev) => {
|
|
83
106
|
const fieldSchema = getFormatSchema(_props.format);
|
|
84
107
|
if (prev.fieldSchema === fieldSchema) {
|
|
@@ -99,8 +122,10 @@ export const FieldEditor = ({
|
|
|
99
122
|
|
|
100
123
|
setProps((props) => {
|
|
101
124
|
const type = formatToType[_props.format as keyof typeof formatToType];
|
|
125
|
+
const additionalProps =
|
|
126
|
+
formatToAdditionalPropertyAttributes[_props.format as keyof typeof formatToAdditionalPropertyAttributes];
|
|
102
127
|
if (props.type !== type) {
|
|
103
|
-
return { ...props, ..._props, type };
|
|
128
|
+
return { ...props, ..._props, ...additionalProps, type } as PropertyType;
|
|
104
129
|
}
|
|
105
130
|
|
|
106
131
|
return _props as PropertyType;
|
|
@@ -109,9 +134,9 @@ export const FieldEditor = ({
|
|
|
109
134
|
[schemas, props.format, props.referenceSchema],
|
|
110
135
|
);
|
|
111
136
|
|
|
112
|
-
const handleValidate = useCallback<NonNullable<
|
|
137
|
+
const handleValidate = useCallback<NonNullable<FormRootProps<PropertyType>['onValidate']>>(
|
|
113
138
|
({ property }) => {
|
|
114
|
-
if (property && projection.
|
|
139
|
+
if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {
|
|
115
140
|
return [
|
|
116
141
|
{
|
|
117
142
|
path: 'property',
|
|
@@ -120,84 +145,53 @@ export const FieldEditor = ({
|
|
|
120
145
|
];
|
|
121
146
|
}
|
|
122
147
|
},
|
|
123
|
-
[projection.
|
|
148
|
+
[projection.getFields(), field],
|
|
124
149
|
);
|
|
125
150
|
|
|
126
|
-
const handleSave = useCallback<NonNullable<
|
|
151
|
+
const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(
|
|
127
152
|
(props) => {
|
|
128
|
-
|
|
153
|
+
if (view) {
|
|
154
|
+
Obj.change(view, () => {
|
|
155
|
+
projection.setFieldProjection({ field, props });
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
projection.setFieldProjection({ field, props });
|
|
159
|
+
}
|
|
129
160
|
onSave();
|
|
130
161
|
},
|
|
131
|
-
[projection, field, onSave],
|
|
162
|
+
[projection, field, view, onSave],
|
|
132
163
|
);
|
|
133
164
|
|
|
134
|
-
const handleCancel = useCallback<NonNullable<
|
|
165
|
+
const handleCancel = useCallback<NonNullable<FormRootProps<PropertyType>['onCancel']>>(() => {
|
|
166
|
+
onSave();
|
|
135
167
|
// Need to defer to allow form to close.
|
|
136
168
|
requestAnimationFrame(() => onCancel?.());
|
|
137
|
-
onSave();
|
|
138
169
|
}, [onSave]);
|
|
139
170
|
|
|
140
|
-
const custom: Partial<Record<string, InputComponent>> = useMemo(
|
|
141
|
-
() => ({
|
|
142
|
-
['format' satisfies keyof PropertyType]: (props) => (
|
|
143
|
-
<SelectInput
|
|
144
|
-
{...props}
|
|
145
|
-
options={FormatEnums.filter((value) => value !== FormatEnum.None).map((value) => ({
|
|
146
|
-
value,
|
|
147
|
-
label: t(`format ${value}`),
|
|
148
|
-
}))}
|
|
149
|
-
/>
|
|
150
|
-
),
|
|
151
|
-
['referenceSchema' satisfies keyof PropertyType]: (props) => (
|
|
152
|
-
<SelectInput
|
|
153
|
-
{...props}
|
|
154
|
-
options={schemas.map((schema) => ({
|
|
155
|
-
value: schema.typename,
|
|
156
|
-
}))}
|
|
157
|
-
/>
|
|
158
|
-
),
|
|
159
|
-
['referencePath' satisfies keyof PropertyType]: (props) => (
|
|
160
|
-
<SelectInput
|
|
161
|
-
{...props}
|
|
162
|
-
options={
|
|
163
|
-
referenceSchema
|
|
164
|
-
? getSchemaProperties(referenceSchema.ast)
|
|
165
|
-
.sort(sortProperties)
|
|
166
|
-
.map((p) => ({ value: p.name }))
|
|
167
|
-
: []
|
|
168
|
-
}
|
|
169
|
-
/>
|
|
170
|
-
),
|
|
171
|
-
['options' satisfies keyof PropertyType]: (props) => <SelectOptionInput {...props} />,
|
|
172
|
-
}),
|
|
173
|
-
[t, schemas, referenceSchema],
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
const propIsNotType = useCallback(
|
|
177
|
-
(props: SchemaProperty<PropertyType>[]) => props.filter((p) => p.name !== 'type'),
|
|
178
|
-
[],
|
|
179
|
-
);
|
|
180
|
-
|
|
181
171
|
if (!fieldSchema) {
|
|
182
172
|
log.warn('invalid format', { props });
|
|
183
173
|
return null;
|
|
184
174
|
}
|
|
185
175
|
|
|
186
176
|
return (
|
|
187
|
-
<Form<PropertyType>
|
|
177
|
+
<Form.Root<PropertyType>
|
|
188
178
|
key={field.id}
|
|
179
|
+
fieldMap={fieldMap}
|
|
189
180
|
autoFocus
|
|
190
181
|
readonly={readonly}
|
|
191
|
-
values={props}
|
|
192
182
|
schema={fieldSchema}
|
|
193
|
-
|
|
183
|
+
values={props}
|
|
184
|
+
exclude={propIsNotType}
|
|
194
185
|
sort={['property', 'format']}
|
|
195
186
|
onValuesChanged={handleValuesChanged}
|
|
196
187
|
onValidate={handleValidate}
|
|
197
188
|
onSave={handleSave}
|
|
198
189
|
onCancel={handleCancel}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
>
|
|
191
|
+
<Form.Content>
|
|
192
|
+
<Form.FieldSet />
|
|
193
|
+
<Form.Actions />
|
|
194
|
+
</Form.Content>
|
|
195
|
+
</Form.Root>
|
|
202
196
|
);
|
|
203
197
|
};
|
|
@@ -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)
|