@dxos/react-ui-form 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8
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/README.md +0 -1
- package/dist/lib/browser/index.mjs +4005 -2402
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +87 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +4005 -2402
- 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 +89 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +8 -7
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +73 -59
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +135 -27
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +192 -137
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +52 -0
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +98 -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 +26 -0
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -0
- 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 +123 -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 +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/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 +5 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
- 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 +11 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +89 -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 +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 +34 -0
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/RefField.test.d.ts +2 -0
- package/dist/types/src/components/Form/fields/RefField.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectField.d.ts +13 -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 +89 -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 +14 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/index.d.ts +5 -4
- 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/ObjectForm.stories.d.ts +87 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.stories.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 +39 -12
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +69 -58
- 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 +132 -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 +91 -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/RefEditor/RefEditor.d.ts +73 -0
- package/dist/types/src/components/RefEditor/RefEditor.d.ts.map +1 -0
- package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts +92 -0
- package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/RefEditor/index.d.ts +3 -0
- package/dist/types/src/components/RefEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts +47 -0
- package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.d.ts +51 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts +89 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- 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 +4 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +15 -19
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +75 -64
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +13 -6
- 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/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +70 -59
- 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 +35 -0
- package/dist/types/src/util/properties.d.ts.map +1 -0
- 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 +2 -2
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -52
- package/src/components/FieldEditor/FieldEditor.stories.tsx +44 -25
- package/src/components/FieldEditor/FieldEditor.test.tsx +4 -2
- package/src/components/FieldEditor/FieldEditor.tsx +91 -86
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +147 -252
- package/src/components/Form/Form.tsx +461 -108
- package/src/components/Form/FormField.tsx +345 -0
- package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
- package/src/components/Form/FormFieldComponent.tsx +253 -0
- package/src/components/Form/FormFieldSet.tsx +213 -0
- 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/README.md +3 -0
- package/src/components/Form/fields/ArrayField.tsx +173 -0
- package/src/components/Form/fields/BooleanField.tsx +22 -0
- package/src/components/Form/fields/DateField.tsx +101 -0
- package/src/components/Form/fields/GeoPointField.tsx +124 -0
- package/src/components/Form/fields/InlineRefField.tsx +138 -0
- package/src/components/Form/fields/MarkdownField.stories.tsx +206 -0
- package/src/components/Form/fields/MarkdownField.tsx +167 -0
- package/src/components/Form/fields/NumberField.tsx +76 -0
- package/src/components/Form/fields/RefField.test.ts +45 -0
- package/src/components/Form/fields/RefField.tsx +266 -0
- package/src/components/Form/fields/SelectField.tsx +77 -0
- package/src/components/Form/{custom/SelectOptionsInput.stories.tsx → fields/SelectOptionField.stories.tsx} +23 -18
- package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +33 -26
- 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 -9
- package/src/components/Form/fields/index.ts +17 -0
- package/src/components/Form/index.ts +6 -4
- package/src/components/Form/meta-tags.test.ts +47 -0
- package/src/components/Form/meta-tags.ts +33 -0
- package/src/components/ObjectForm/ObjectForm.stories.tsx +62 -0
- package/src/components/ObjectForm/ObjectForm.tsx +111 -0
- package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +26 -21
- package/src/components/ObjectPicker/ObjectPicker.tsx +123 -82
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +350 -0
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +111 -0
- package/src/components/ObjectProperties/ObjectProperties.tsx +146 -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/RefEditor/RefEditor.stories.tsx +148 -0
- package/src/components/RefEditor/RefEditor.tsx +275 -0
- package/src/components/RefEditor/index.ts +6 -0
- package/src/components/RefEditor/ref-editor-extension.ts +254 -0
- package/src/components/Settings/AUDIT.md +51 -0
- package/src/components/Settings/Settings.stories.tsx +104 -0
- package/src/components/Settings/Settings.tsx +81 -0
- 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 +7 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +70 -76
- package/src/components/ViewEditor/ViewEditor.test.tsx +17 -13
- package/src/components/ViewEditor/ViewEditor.tsx +340 -226
- package/src/components/index.ts +5 -1
- package/src/components/testing.tsx +24 -11
- package/src/hooks/index.ts +2 -3
- package/src/hooks/useFormHandler.ts +380 -0
- package/src/hooks/useKeyHandler.tsx +37 -0
- package/src/index.ts +0 -4
- package/src/translations.ts +76 -64
- package/src/util/field-type.ts +60 -0
- package/src/util/field.ts +25 -25
- package/src/util/formatting.ts +22 -22
- package/src/util/index.ts +2 -1
- package/src/util/properties.test.ts +153 -0
- package/src/util/properties.ts +100 -0
- package/src/util/refs.ts +16 -15
- package/src/vite-env.d.ts +10 -0
- 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 -83
- 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 -63
- 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 -29
- package/dist/types/src/components/Form/Input.d.ts.map +0 -1
- package/dist/types/src/components/Form/RefField.d.ts +0 -22
- 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 -78
- 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/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 -29
- 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 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
- package/src/components/Form/ArrayField.tsx +0 -125
- package/src/components/Form/Defaults.tsx +0 -205
- package/src/components/Form/FormActions.tsx +0 -54
- package/src/components/Form/FormContent.tsx +0 -362
- package/src/components/Form/FormContext.tsx +0 -110
- package/src/components/Form/Input.tsx +0 -54
- package/src/components/Form/RefField.tsx +0 -283
- package/src/components/Form/custom/GeoPointInput.tsx +0 -80
- package/src/components/Form/custom/index.ts +0 -7
- package/src/components/Form/factory.tsx +0 -31
- package/src/hooks/useForm.ts +0 -296
- package/src/hooks/useQueryRefOptions.ts +0 -62
- package/src/hooks/useRefQueryLookupHandler.ts +0 -39
- package/src/util/schema.ts +0 -12
|
@@ -1,122 +1,475 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import { type
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import { type
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext } from '@radix-ui/react-context';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
|
+
import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Annotation as EchoAnnotation, Type } from '@dxos/echo';
|
|
12
|
+
import { type AnyProperties } from '@dxos/echo/internal';
|
|
13
|
+
import { SchemaEx } from '@dxos/effect';
|
|
14
|
+
import {
|
|
15
|
+
Column,
|
|
16
|
+
type ColumnRootProps,
|
|
17
|
+
IconButton,
|
|
18
|
+
type IconButtonProps,
|
|
19
|
+
Input,
|
|
20
|
+
ScrollArea,
|
|
21
|
+
type ThemedClassName,
|
|
22
|
+
useMergeRefs,
|
|
23
|
+
useTranslation,
|
|
24
|
+
} from '@dxos/react-ui';
|
|
25
|
+
import { composable, composableProps, withColumn } from '@dxos/react-ui';
|
|
26
|
+
import { mx } from '@dxos/ui-theme';
|
|
27
|
+
|
|
28
|
+
import { translationKey } from '#translations';
|
|
29
|
+
|
|
30
|
+
import {
|
|
31
|
+
type FormHandler,
|
|
32
|
+
type FormHandlerProps,
|
|
33
|
+
type FormUpdateMeta,
|
|
34
|
+
useFormHandler,
|
|
35
|
+
useKeyHandler,
|
|
36
|
+
} from '../../hooks';
|
|
37
|
+
import { FormFieldLabel, type FormFieldLabelProps, type FormFieldStateProps } from './FormFieldComponent';
|
|
38
|
+
import {
|
|
39
|
+
FormFieldSet as NaturalFormFieldSet,
|
|
40
|
+
type FormFieldSetProps as NaturalFormFieldSetProps,
|
|
41
|
+
} from './FormFieldSet';
|
|
42
|
+
import { FormTooltipsContext } from './FormTooltipsContext';
|
|
43
|
+
import { FormLayout as NaturalFormLayout } from './Layout';
|
|
44
|
+
import { type FormLayoutProps as NaturalFormLayoutProps } from './Layout/FormLayout';
|
|
45
|
+
|
|
46
|
+
// TODO(burdon): Move styles to form.ts (as with ui-theme).
|
|
47
|
+
|
|
48
|
+
// TODO(burdon): Reconcile with @dxos/echo.
|
|
49
|
+
export type ExcludeId<S extends Schema.Schema.AnyNoContext | Type.AnyEntity> = Omit<
|
|
50
|
+
S extends Type.AnyEntity
|
|
51
|
+
? Type.InstanceType<S>
|
|
52
|
+
: S extends Schema.Schema.AnyNoContext
|
|
53
|
+
? Schema.Schema.Type<S>
|
|
54
|
+
: never,
|
|
55
|
+
'id'
|
|
56
|
+
>;
|
|
57
|
+
|
|
58
|
+
// TODO(burdon): Move to @dxos/schema (re-export here).
|
|
59
|
+
export const omitId = <S extends Schema.Schema.AnyNoContext | Type.AnyEntity>(
|
|
60
|
+
schemaOrType: S,
|
|
61
|
+
): Schema.Schema<ExcludeId<S>, ExcludeId<S>> => {
|
|
62
|
+
const schema = Type.isType(schemaOrType)
|
|
63
|
+
? Type.getSchema(schemaOrType)
|
|
64
|
+
: (schemaOrType as Schema.Schema.AnyNoContext);
|
|
65
|
+
return schema.pipe(Schema.omit('id')) as any;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Drop fields annotated with `FormInputAnnotation.set(false)` from a schema so
|
|
70
|
+
* the form's validator doesn't trip on required-but-hidden fields. Used by
|
|
71
|
+
* the picker's inline create form, where a `FactoryAnnotation` typically
|
|
72
|
+
* supplies the hidden values (e.g. a backing-object Ref) outside the form.
|
|
73
|
+
*/
|
|
74
|
+
export const omitHiddenFormFields = <S extends Schema.Schema.AnyNoContext>(schema: S): S => {
|
|
75
|
+
const properties = SchemaAST.getPropertySignatures(schema.ast);
|
|
76
|
+
const hidden = properties
|
|
77
|
+
.filter((prop) => Option.getOrElse(EchoAnnotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false)
|
|
78
|
+
.map((prop) => prop.name as string);
|
|
79
|
+
return hidden.length === 0 ? schema : (schema.pipe(Schema.omit(...(hidden as [string, ...string[]]))) as any);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//
|
|
83
|
+
// Context
|
|
84
|
+
//
|
|
85
|
+
|
|
86
|
+
type FormContextValue<T extends AnyProperties = any> = {
|
|
87
|
+
/**
|
|
88
|
+
* Form handler.
|
|
89
|
+
*/
|
|
90
|
+
form: FormHandler<T>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Show field tooltips (currently: JSON path on each label). Defaults to
|
|
94
|
+
* `true`; pass `false` to suppress.
|
|
95
|
+
*/
|
|
96
|
+
tooltips?: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Testing.
|
|
100
|
+
*/
|
|
101
|
+
testId?: string;
|
|
102
|
+
} & Pick<
|
|
103
|
+
NaturalFormFieldSetProps<T>,
|
|
104
|
+
'readonly' | 'layout' | 'fieldMap' | 'fieldProvider' | 'projection' | 'createTypename' | 'createFieldMap' | 'db'
|
|
105
|
+
>;
|
|
106
|
+
|
|
107
|
+
const [FormContextProvider, useFormContext] = createContext<FormContextValue>('Form');
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get the current form values.
|
|
111
|
+
*/
|
|
112
|
+
const useFormValues: {
|
|
113
|
+
<T extends AnyProperties>(componentName: string, path?: (string | number)[]): T;
|
|
114
|
+
<T extends AnyProperties>(
|
|
115
|
+
componentName: string,
|
|
116
|
+
path: (string | number)[] | undefined,
|
|
117
|
+
defaultValue: () => T,
|
|
118
|
+
): T | undefined;
|
|
119
|
+
} = (componentName: string, path?: (string | number)[], defaultValue?: () => any) => {
|
|
120
|
+
const stablePath = useMemo(() => path ?? [], [path ? path.join('.') : undefined]);
|
|
121
|
+
const jsonPath = SchemaEx.createJsonPath(stablePath);
|
|
122
|
+
const {
|
|
123
|
+
form: { values, onValueChange },
|
|
124
|
+
} = useFormContext(componentName);
|
|
125
|
+
|
|
126
|
+
const value = SchemaEx.getValue(values, jsonPath);
|
|
127
|
+
|
|
128
|
+
// Apply default value once when the field has no value. lastAppliedPathRef prevents
|
|
129
|
+
// re-applying on every render (e.g. when defaultValue() returns null) and ensures
|
|
130
|
+
// we apply per path when the hook is used for different fields.
|
|
131
|
+
const lastAppliedPathRef = useRef<string | null>(null);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (value == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
|
|
134
|
+
lastAppliedPathRef.current = jsonPath;
|
|
135
|
+
onValueChange(stablePath, SchemaAST.stringKeyword, defaultValue());
|
|
136
|
+
}
|
|
137
|
+
}, [value, defaultValue, onValueChange, stablePath, jsonPath]);
|
|
138
|
+
|
|
139
|
+
return value;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get the state props for the given field.
|
|
144
|
+
*/
|
|
145
|
+
const useFormFieldState = (componentName: string, path: (string | number)[] = []): FormFieldStateProps => {
|
|
146
|
+
const stablePath = useMemo(() => path, [Array.isArray(path) ? path.join('.') : path]);
|
|
147
|
+
const {
|
|
148
|
+
form: { getStatus, getValue, onBlur, onValueChange },
|
|
149
|
+
} = useFormContext(componentName);
|
|
150
|
+
|
|
151
|
+
return useMemo(
|
|
152
|
+
() => ({
|
|
153
|
+
getStatus: () => getStatus(stablePath),
|
|
154
|
+
getValue: () => getValue(stablePath),
|
|
155
|
+
onBlur: () => onBlur(stablePath),
|
|
156
|
+
onValueChange: (ast: SchemaAST.AST, value: any) => onValueChange(stablePath, ast, value),
|
|
157
|
+
}),
|
|
158
|
+
[getStatus, getValue, onBlur, onValueChange, stablePath],
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
//
|
|
163
|
+
// Root
|
|
164
|
+
//
|
|
165
|
+
|
|
166
|
+
type FormRootProps<T extends AnyProperties = AnyProperties> = PropsWithChildren<
|
|
167
|
+
{
|
|
168
|
+
/**
|
|
169
|
+
* Called when the form is submitted and passes validation.
|
|
170
|
+
*/
|
|
171
|
+
onSave?: (values: T, meta: FormUpdateMeta<T>) => void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Called when the form is canceled to abandon/undo any pending changes.
|
|
175
|
+
*/
|
|
176
|
+
onCancel?: () => void;
|
|
177
|
+
} & Omit<FormContextValue<T>, 'form'> &
|
|
178
|
+
Pick<FormHandlerProps<T>, 'schema' | 'autoSave' | 'values' | 'defaultValues' | 'onValidate' | 'onValuesChanged'> &
|
|
179
|
+
Omit<NaturalFormFieldSetProps<T>, 'schema' | 'path'>
|
|
180
|
+
>;
|
|
181
|
+
|
|
182
|
+
const FormRoot = <T extends AnyProperties = AnyProperties>({
|
|
183
|
+
children,
|
|
57
184
|
schema,
|
|
58
|
-
|
|
59
|
-
onValuesChanged,
|
|
60
|
-
onValidate,
|
|
185
|
+
values,
|
|
61
186
|
onSave,
|
|
187
|
+
onCancel,
|
|
62
188
|
...props
|
|
63
|
-
}:
|
|
64
|
-
const
|
|
189
|
+
}: FormRootProps<T>) => {
|
|
190
|
+
const form = useFormHandler({ schema, values, onSave, onCancel, ...props });
|
|
65
191
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
192
|
+
return (
|
|
193
|
+
<FormTooltipsContext.Provider value={props.tooltips ?? true}>
|
|
194
|
+
<FormContextProvider form={form} {...props}>
|
|
195
|
+
{children}
|
|
196
|
+
</FormContextProvider>
|
|
197
|
+
</FormTooltipsContext.Provider>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
FormRoot.displayName = 'Form.Root';
|
|
202
|
+
|
|
203
|
+
//
|
|
204
|
+
// Viewport
|
|
205
|
+
//
|
|
206
|
+
|
|
207
|
+
const FORM_VIEWPORT_NAME = 'Form.Viewport';
|
|
208
|
+
|
|
209
|
+
type FormViewportProps = { scroll?: boolean; gutter?: ColumnRootProps['gutter'] };
|
|
210
|
+
|
|
211
|
+
// The viewing window: owns the gutter Column (chrome/side-padding).
|
|
212
|
+
// Content-height by default; `scroll` makes it fill its parent and scroll (the gutter then hosts the scrollbar).
|
|
213
|
+
const FormViewport = composable<HTMLDivElement, FormViewportProps>(
|
|
214
|
+
({ children, scroll, gutter = 'xs', ...props }, forwardedRef) => {
|
|
215
|
+
// Span the full width when nested inside another Column grid (e.g. Card.Root)
|
|
216
|
+
// instead of landing in a single narrow track.
|
|
217
|
+
const span = '[.dx-column-root_&]:col-span-full';
|
|
218
|
+
if (scroll) {
|
|
219
|
+
return (
|
|
220
|
+
<Column.Root gutter={gutter} classNames={['dx-expander', span]}>
|
|
221
|
+
<ScrollArea.Root {...composableProps(props)} orientation='vertical' centered padding thin ref={forwardedRef}>
|
|
222
|
+
<ScrollArea.Viewport>{children}</ScrollArea.Viewport>
|
|
223
|
+
</ScrollArea.Root>
|
|
224
|
+
</Column.Root>
|
|
225
|
+
);
|
|
74
226
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<Column.Root {...composableProps(props)} gutter={gutter} classNames={['w-full min-w-0', span]} ref={forwardedRef}>
|
|
230
|
+
{children}
|
|
231
|
+
</Column.Root>
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
237
|
+
|
|
238
|
+
//
|
|
239
|
+
// Content
|
|
240
|
+
//
|
|
241
|
+
|
|
242
|
+
const FORM_CONTENT_NAME = 'Form.Content';
|
|
243
|
+
|
|
244
|
+
type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;
|
|
245
|
+
|
|
246
|
+
// The viewed body: centered in the viewport's gutter. Pure body — the gutter Column is owned by `Form.Viewport`.
|
|
247
|
+
const FormContent = composable<HTMLDivElement, FormContentProps>(({ children, ...props }, forwardedRef) => {
|
|
248
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
249
|
+
const localRef = useRef<HTMLDivElement>(null);
|
|
250
|
+
const mergedRef = useMergeRefs([forwardedRef, localRef]);
|
|
251
|
+
useKeyHandler(localRef, form);
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div
|
|
255
|
+
{...composableProps(props, {
|
|
256
|
+
role: 'form',
|
|
257
|
+
classNames: mx(withColumn.center(), 'flex flex-col w-full'),
|
|
258
|
+
})}
|
|
259
|
+
data-testid={testId}
|
|
260
|
+
ref={mergedRef}
|
|
261
|
+
>
|
|
262
|
+
{children}
|
|
263
|
+
</div>
|
|
85
264
|
);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
268
|
+
|
|
269
|
+
//
|
|
270
|
+
// FieldSet
|
|
271
|
+
//
|
|
272
|
+
|
|
273
|
+
const FORM_FIELDSET_NAME = 'Form.FieldSet';
|
|
274
|
+
|
|
275
|
+
type FormFieldSetProps = ThemedClassName<NaturalFormFieldSetProps<any>>;
|
|
276
|
+
|
|
277
|
+
const FormFieldSet = (props: FormFieldSetProps) => {
|
|
278
|
+
const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME);
|
|
279
|
+
|
|
280
|
+
return <NaturalFormFieldSet schema={form.schema} {...contextProps} {...props} />;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
284
|
+
|
|
285
|
+
//
|
|
286
|
+
// Layout
|
|
287
|
+
//
|
|
288
|
+
|
|
289
|
+
const FORM_LAYOUT_NAME = 'Form.Layout';
|
|
290
|
+
|
|
291
|
+
type FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & { schema?: NaturalFormLayoutProps['schema'] };
|
|
292
|
+
|
|
293
|
+
const FormLayout = ({ schema, ...props }: FormLayoutProps) => {
|
|
294
|
+
const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME);
|
|
295
|
+
const resolvedSchema = schema ?? form.schema;
|
|
296
|
+
if (!resolvedSchema) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return <NaturalFormLayout schema={resolvedSchema} {...contextProps} {...props} />;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
FormLayout.displayName = FORM_LAYOUT_NAME;
|
|
304
|
+
|
|
305
|
+
//
|
|
306
|
+
// Actions
|
|
307
|
+
//
|
|
308
|
+
|
|
309
|
+
const FORM_ACTIONS_NAME = 'Form.Actions';
|
|
310
|
+
|
|
311
|
+
type FormActionsProps = ThemedClassName<{}>;
|
|
312
|
+
|
|
313
|
+
const FormActions = ({ classNames }: FormActionsProps) => {
|
|
314
|
+
const { t } = useTranslation(translationKey);
|
|
315
|
+
const {
|
|
316
|
+
form: { canSave, onSave, onCancel },
|
|
317
|
+
readonly,
|
|
318
|
+
layout,
|
|
319
|
+
} = useFormContext(FORM_ACTIONS_NAME);
|
|
320
|
+
|
|
321
|
+
if (readonly || layout === 'static') {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// TODO(burdon): Currently onCancel is a no-op; implement "revert values".
|
|
326
|
+
// Deprecate FormSubmit ans use FormActions without Cancel button if no callback is supplied.
|
|
86
327
|
|
|
87
328
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
schema={schema}
|
|
91
|
-
autoSave={autoSave}
|
|
92
|
-
initialValues={initialValues}
|
|
93
|
-
onValuesChanged={onValuesChanged}
|
|
94
|
-
onValidate={onValidate}
|
|
95
|
-
onValid={handleValid}
|
|
96
|
-
onSave={onSave}
|
|
329
|
+
<div
|
|
330
|
+
className={mx(withColumn.center(), 'grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding', classNames)}
|
|
97
331
|
>
|
|
98
|
-
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
332
|
+
{onCancel && (
|
|
333
|
+
<IconButton
|
|
334
|
+
icon='ph--x--regular'
|
|
335
|
+
iconEnd
|
|
336
|
+
label={t('cancel-button.label')}
|
|
337
|
+
onClick={onCancel}
|
|
338
|
+
data-testid='cancel-button'
|
|
339
|
+
/>
|
|
340
|
+
)}
|
|
341
|
+
{onSave && (
|
|
342
|
+
<IconButton
|
|
343
|
+
type='submit'
|
|
344
|
+
variant='primary'
|
|
345
|
+
disabled={!canSave}
|
|
346
|
+
icon='ph--check--regular'
|
|
347
|
+
iconEnd
|
|
348
|
+
label={t('save-button.label')}
|
|
349
|
+
onClick={onSave}
|
|
350
|
+
data-testid='save-button'
|
|
115
351
|
/>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
352
|
+
)}
|
|
353
|
+
</div>
|
|
354
|
+
);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
358
|
+
|
|
359
|
+
//
|
|
360
|
+
// Section
|
|
361
|
+
//
|
|
362
|
+
|
|
363
|
+
const FORM_SECTION_NAME = 'Form.Section';
|
|
364
|
+
|
|
365
|
+
type FormSectionProps = ThemedClassName<{ label?: string; description?: string }>;
|
|
366
|
+
|
|
367
|
+
const FormSection = composable<HTMLDivElement, FormSectionProps>(
|
|
368
|
+
({ children, label, description, ...props }, forwardedRef) => {
|
|
369
|
+
return (
|
|
370
|
+
<div
|
|
371
|
+
{...composableProps(props, { classNames: 'flex flex-col pt-form-section-gap first:pt-0' })}
|
|
372
|
+
ref={forwardedRef}
|
|
373
|
+
>
|
|
374
|
+
{label && <h2 className='text-lg'>{label}</h2>}
|
|
375
|
+
{description && <p className='text-description'>{description}</p>}
|
|
376
|
+
{children}
|
|
119
377
|
</div>
|
|
120
|
-
|
|
378
|
+
);
|
|
379
|
+
},
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
FormSection.displayName = FORM_SECTION_NAME;
|
|
383
|
+
|
|
384
|
+
//
|
|
385
|
+
// Submit
|
|
386
|
+
//
|
|
387
|
+
|
|
388
|
+
const FORM_SUBMIT_NAME = 'Form.Submit';
|
|
389
|
+
|
|
390
|
+
type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;
|
|
391
|
+
|
|
392
|
+
const FormSubmit = ({ classNames, label, icon, disabled }: FormSubmitProps) => {
|
|
393
|
+
const { t } = useTranslation(translationKey);
|
|
394
|
+
const {
|
|
395
|
+
form: { canSave, onSave },
|
|
396
|
+
readonly,
|
|
397
|
+
layout,
|
|
398
|
+
} = useFormContext(FORM_SUBMIT_NAME);
|
|
399
|
+
|
|
400
|
+
if (readonly || layout === 'static') {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return (
|
|
405
|
+
<div className={mx('flex w-full pt-form-padding', classNames)}>
|
|
406
|
+
<IconButton
|
|
407
|
+
classNames='w-full'
|
|
408
|
+
type='submit'
|
|
409
|
+
variant='primary'
|
|
410
|
+
disabled={disabled ?? !canSave}
|
|
411
|
+
icon={icon ?? 'ph--check--regular'}
|
|
412
|
+
label={label ?? t('save-button.label')}
|
|
413
|
+
onClick={onSave}
|
|
414
|
+
data-testid='save-button'
|
|
415
|
+
/>
|
|
416
|
+
</div>
|
|
121
417
|
);
|
|
122
418
|
};
|
|
419
|
+
|
|
420
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
421
|
+
|
|
422
|
+
//
|
|
423
|
+
// Error
|
|
424
|
+
//
|
|
425
|
+
|
|
426
|
+
const FORM_ERROR_NAME = 'Form.Error';
|
|
427
|
+
|
|
428
|
+
type FormErrorProps = ThemedClassName<PropsWithChildren>;
|
|
429
|
+
|
|
430
|
+
/** Form-level error/validation message (e.g. a failed submit), styled via the error valence. */
|
|
431
|
+
const FormError = ({ children, classNames }: FormErrorProps) => {
|
|
432
|
+
if (!children) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<Input.Root validationValence='error'>
|
|
438
|
+
<Input.Validation classNames={classNames}>{children}</Input.Validation>
|
|
439
|
+
</Input.Root>
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
FormError.displayName = FORM_ERROR_NAME;
|
|
444
|
+
|
|
445
|
+
//
|
|
446
|
+
// Form
|
|
447
|
+
// https://www.radix-ui.com/primitives/docs/guides/composition
|
|
448
|
+
//
|
|
449
|
+
|
|
450
|
+
export const Form = {
|
|
451
|
+
Root: FormRoot,
|
|
452
|
+
Viewport: FormViewport,
|
|
453
|
+
Content: FormContent,
|
|
454
|
+
Section: FormSection,
|
|
455
|
+
FieldSet: FormFieldSet,
|
|
456
|
+
Layout: FormLayout,
|
|
457
|
+
Label: FormFieldLabel,
|
|
458
|
+
Actions: FormActions,
|
|
459
|
+
Submit: FormSubmit,
|
|
460
|
+
Error: FormError,
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
export { useFormContext, useFormValues, useFormFieldState };
|
|
464
|
+
|
|
465
|
+
export type {
|
|
466
|
+
FormRootProps,
|
|
467
|
+
FormViewportProps,
|
|
468
|
+
FormContentProps,
|
|
469
|
+
FormSectionProps,
|
|
470
|
+
FormFieldSetProps,
|
|
471
|
+
FormLayoutProps,
|
|
472
|
+
FormFieldLabelProps,
|
|
473
|
+
FormActionsProps,
|
|
474
|
+
FormSubmitProps,
|
|
475
|
+
};
|