@dxos/react-ui-form 0.9.0 → 0.9.1-main.c7dcc2e112
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/dist/lib/browser/index.mjs +2221 -2147
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +2221 -2147
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +15 -110
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +3 -37
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormControls.d.ts +66 -0
- package/dist/types/src/components/Form/FormControls.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/FieldHeader.d.ts +19 -0
- package/dist/types/src/components/Form/FormField/FieldHeader.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/FormField.d.ts +30 -0
- package/dist/types/src/components/Form/FormField/FormField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/FormFieldWrapper.d.ts +47 -0
- package/dist/types/src/components/Form/FormField/FormFieldWrapper.d.ts.map +1 -0
- package/dist/types/src/components/Form/{FormFieldComponent.stories.d.ts → FormField/FormFieldWrapper.stories.d.ts} +3 -3
- package/dist/types/src/components/Form/FormField/FormFieldWrapper.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields/ArrayField}/ArrayField.d.ts +2 -2
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts +87 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.d.ts +4 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.d.ts +4 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields/GeoPointField}/GeoPointField.d.ts +2 -2
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.d.ts +2 -2
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts +4 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/InlineRefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts +16 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts +92 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts +3 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields/SelectField}/SelectField.d.ts +2 -2
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.d.ts +5 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.d.ts +4 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.d.ts +4 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields/TupleField}/TupleField.d.ts +2 -2
- package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts +88 -0
- package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/TupleField/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormField/fields/TupleField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{fields → FormField/fields}/index.d.ts +0 -1
- package/dist/types/src/components/Form/FormField/fields/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/index.d.ts +5 -0
- package/dist/types/src/components/Form/FormField/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/{FormFieldSet.d.ts → FormFieldSet/FormFieldSet.d.ts} +4 -3
- package/dist/types/src/components/Form/FormFieldSet/FormFieldSet.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldSet/index.d.ts +2 -0
- package/dist/types/src/components/Form/FormFieldSet/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/FormLayout.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/FormLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/FormLayout.stories.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/FormLayout.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/index.d.ts +3 -0
- package/dist/types/src/components/Form/FormLayout/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/parser.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormLayout/parser.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/index.d.ts +3 -5
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/meta-tags.d.ts +2 -2
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +6 -23
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
- package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormContext.d.ts +37 -0
- package/dist/types/src/hooks/useFormContext.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormHandler.d.ts +1 -4
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/{components/testing.d.ts → testing/TestLayout.d.ts} +1 -1
- package/dist/types/src/testing/TestLayout.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/schema.d.ts +43 -0
- package/dist/types/src/testing/schema.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +112 -0
- package/dist/types/src/types.d.ts.map +1 -0
- 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/omit.d.ts +12 -0
- package/dist/types/src/util/omit.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -34
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/FieldEditor/FieldEditor.test.tsx +1 -1
- package/src/components/FieldEditor/FieldEditor.tsx +5 -4
- package/src/components/Form/Form.stories.tsx +4 -49
- package/src/components/Form/Form.tsx +18 -447
- package/src/components/Form/FormControls.tsx +320 -0
- package/src/components/Form/FormField/FieldHeader.tsx +36 -0
- package/src/components/Form/{FormField.tsx → FormField/FormField.tsx} +35 -59
- package/src/components/Form/{FormFieldComponent.stories.tsx → FormField/FormFieldWrapper.stories.tsx} +24 -17
- package/src/components/Form/{FormFieldComponent.tsx → FormField/FormFieldWrapper.tsx} +21 -95
- package/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.tsx +103 -0
- package/src/components/Form/FormField/fields/ArrayField/ArrayField.tsx +269 -0
- package/src/components/Form/FormField/fields/ArrayField/index.ts +5 -0
- package/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.tsx +52 -0
- package/src/components/Form/{fields → FormField/fields/BooleanField}/BooleanField.tsx +10 -3
- package/src/components/Form/FormField/fields/BooleanField/index.ts +5 -0
- package/src/components/Form/FormField/fields/DateField/DateField.stories.tsx +60 -0
- package/src/components/Form/{fields → FormField/fields/DateField}/DateField.tsx +4 -2
- package/src/components/Form/FormField/fields/DateField/index.ts +5 -0
- package/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.tsx +53 -0
- package/src/components/Form/{fields → FormField/fields/GeoPointField}/GeoPointField.tsx +4 -3
- package/src/components/Form/FormField/fields/GeoPointField/index.ts +5 -0
- package/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.stories.tsx +6 -6
- package/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.tsx +3 -2
- package/src/components/Form/FormField/fields/MarkdownField/index.ts +5 -0
- package/src/components/Form/FormField/fields/NumberField/NumberField.stories.tsx +52 -0
- package/src/components/Form/{fields → FormField/fields/NumberField}/NumberField.tsx +27 -2
- package/src/components/Form/FormField/fields/NumberField/index.ts +5 -0
- package/src/components/Form/{fields → FormField/fields/RefField}/InlineRefField.tsx +8 -7
- package/src/components/Form/FormField/fields/RefField/RefField.stories.tsx +97 -0
- package/src/components/Form/{fields → FormField/fields/RefField}/RefField.test.ts +2 -1
- package/src/components/Form/{fields → FormField/fields/RefField}/RefField.tsx +6 -25
- package/src/components/Form/FormField/fields/RefField/index.ts +6 -0
- package/src/components/Form/FormField/fields/SelectField/SelectField.stories.tsx +53 -0
- package/src/components/Form/{fields → FormField/fields/SelectField}/SelectField.tsx +4 -2
- package/src/components/Form/FormField/fields/SelectField/index.ts +5 -0
- package/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.stories.tsx +5 -5
- package/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.tsx +55 -53
- package/src/components/Form/FormField/fields/SelectOptionField/index.ts +5 -0
- package/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.tsx +53 -0
- package/src/components/Form/{fields → FormField/fields/TextAreaField}/TextAreaField.tsx +4 -2
- package/src/components/Form/FormField/fields/TextAreaField/index.ts +5 -0
- package/src/components/Form/FormField/fields/TextField/TextField.stories.tsx +52 -0
- package/src/components/Form/{fields → FormField/fields/TextField}/TextField.tsx +4 -2
- package/src/components/Form/FormField/fields/TextField/index.ts +5 -0
- package/src/components/Form/FormField/fields/TupleField/TupleField.stories.tsx +55 -0
- package/src/components/Form/{fields → FormField/fields/TupleField}/TupleField.tsx +4 -2
- package/src/components/Form/FormField/fields/TupleField/index.ts +5 -0
- package/src/components/Form/{fields → FormField/fields}/index.ts +0 -1
- package/src/components/Form/FormField/index.ts +8 -0
- package/src/components/Form/{FormFieldSet.tsx → FormFieldSet/FormFieldSet.tsx} +16 -32
- package/src/components/Form/FormFieldSet/index.ts +5 -0
- package/src/components/Form/{Layout → FormLayout}/FormLayout.stories.tsx +4 -4
- package/src/components/Form/{Layout → FormLayout}/FormLayout.tsx +7 -6
- package/src/components/Form/{Layout → FormLayout}/index.ts +1 -2
- package/src/components/Form/index.ts +3 -5
- package/src/components/Form/meta-tags.ts +1 -1
- package/src/components/ObjectForm/ObjectForm.tsx +15 -14
- package/src/components/ObjectPicker/ObjectPicker.tsx +19 -27
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +1 -1
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +1 -1
- package/src/components/ObjectProperties/ObjectProperties.tsx +2 -1
- package/src/components/RefEditor/RefEditor.stories.tsx +0 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +4 -5
- package/src/components/ViewEditor/ViewEditor.test.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.tsx +98 -128
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useFormContext.ts +86 -0
- package/src/hooks/useFormHandler.ts +1 -4
- package/src/index.ts +1 -0
- package/src/{components/testing.tsx → testing/TestLayout.tsx} +1 -1
- package/src/testing/index.ts +7 -0
- package/src/testing/schema.ts +59 -0
- package/src/types.ts +134 -0
- package/src/util/index.ts +1 -0
- package/src/util/omit.ts +47 -0
- package/src/vitest-setup.ts +40 -0
- package/dist/types/src/components/Form/FormField.d.ts +0 -52
- package/dist/types/src/components/Form/FormField.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -98
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts +0 -19
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/annotation.d.ts +0 -30
- package/dist/types/src/components/Form/Layout/annotation.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/index.d.ts +0 -4
- package/dist/types/src/components/Form/Layout/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/parser.d.ts.map +0 -1
- package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/BooleanField.d.ts +0 -4
- package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/DateField.d.ts +0 -4
- package/dist/types/src/components/Form/fields/DateField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/NumberField.d.ts +0 -4
- package/dist/types/src/components/Form/fields/NumberField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +0 -34
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/RefField.test.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +0 -5
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts +0 -4
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/TextField.d.ts +0 -4
- package/dist/types/src/components/Form/fields/TextField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +0 -1
- package/dist/types/src/components/Form/fields/index.d.ts.map +0 -1
- package/dist/types/src/components/testing.d.ts.map +0 -1
- package/src/components/Form/AUDIT.md +0 -17
- package/src/components/Form/FormTooltipsContext.ts +0 -25
- package/src/components/Form/Layout/annotation.ts +0 -38
- package/src/components/Form/README.md +0 -3
- package/src/components/Form/fields/ArrayField.tsx +0 -173
- /package/dist/types/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.stories.d.ts +0 -0
- /package/dist/types/src/components/Form/{fields → FormField/fields/RefField}/InlineRefField.d.ts +0 -0
- /package/dist/types/src/components/Form/{fields → FormField/fields/RefField}/RefField.test.d.ts +0 -0
- /package/dist/types/src/components/Form/{fields → FormField/fields/SelectOptionField}/SelectOptionField.stories.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.stories.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.stories.test.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/FormLayout.test.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/parser.d.ts +0 -0
- /package/dist/types/src/components/Form/{Layout → FormLayout}/parser.test.d.ts +0 -0
- /package/src/components/Form/{Layout → FormLayout}/FormLayout.stories.test.tsx +0 -0
- /package/src/components/Form/{Layout → FormLayout}/FormLayout.test.ts +0 -0
- /package/src/components/Form/{Layout → FormLayout}/parser.test.ts +0 -0
- /package/src/components/Form/{Layout → FormLayout}/parser.ts +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Format } from '@dxos/echo';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { translations } from '#translations';
|
|
13
|
+
|
|
14
|
+
import { TestLayout } from '../../../../../testing';
|
|
15
|
+
import { Form } from '../../../Form';
|
|
16
|
+
|
|
17
|
+
// DateField covers all three temporal formats; show each.
|
|
18
|
+
const schema = Schema.Struct({
|
|
19
|
+
date: Format.DateOnly.annotations({ title: 'Date' }),
|
|
20
|
+
time: Format.TimeOnly.annotations({ title: 'Time' }),
|
|
21
|
+
dateTime: Format.DateTime.annotations({ title: 'Date & time' }),
|
|
22
|
+
}).pipe(Schema.mutable);
|
|
23
|
+
|
|
24
|
+
type Values = Schema.Schema.Type<typeof schema>;
|
|
25
|
+
|
|
26
|
+
const DefaultStory = () => {
|
|
27
|
+
const [values, setValues] = useState<Values>({
|
|
28
|
+
date: '1990-05-12',
|
|
29
|
+
time: '09:00:00',
|
|
30
|
+
dateTime: '2026-06-01T15:30:00.000Z',
|
|
31
|
+
});
|
|
32
|
+
return (
|
|
33
|
+
<TestLayout json={values}>
|
|
34
|
+
<Form.Root
|
|
35
|
+
schema={schema}
|
|
36
|
+
values={values}
|
|
37
|
+
onValuesChanged={(values) => setValues((prev) => ({ ...prev, ...values }))}
|
|
38
|
+
>
|
|
39
|
+
<Form.Viewport>
|
|
40
|
+
<Form.Content>
|
|
41
|
+
<Form.FieldSet />
|
|
42
|
+
</Form.Content>
|
|
43
|
+
</Form.Viewport>
|
|
44
|
+
</Form.Root>
|
|
45
|
+
</TestLayout>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const meta = {
|
|
50
|
+
title: 'ui/react-ui-form/FormField/DateField',
|
|
51
|
+
render: DefaultStory,
|
|
52
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
53
|
+
parameters: { layout: 'fullscreen', translations },
|
|
54
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
55
|
+
|
|
56
|
+
export default meta;
|
|
57
|
+
|
|
58
|
+
type Story = StoryObj<typeof meta>;
|
|
59
|
+
|
|
60
|
+
export const Default: Story = {};
|
|
@@ -8,7 +8,9 @@ import React, { useCallback } from 'react';
|
|
|
8
8
|
import { Format } from '@dxos/echo';
|
|
9
9
|
import { Input } from '@dxos/react-ui';
|
|
10
10
|
|
|
11
|
-
import { type
|
|
11
|
+
import { type FormFieldRendererProps } from '#types';
|
|
12
|
+
|
|
13
|
+
import { FormFieldWrapper } from '../../FormFieldWrapper';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Stored value shapes:
|
|
@@ -52,7 +54,7 @@ export const DateField = ({
|
|
|
52
54
|
onValueChange,
|
|
53
55
|
onBlur: _onBlur,
|
|
54
56
|
...props
|
|
55
|
-
}:
|
|
57
|
+
}: FormFieldRendererProps<string>) => {
|
|
56
58
|
const handleSimpleChange = useCallback((next: string) => onValueChange(type, next), [type, onValueChange]);
|
|
57
59
|
|
|
58
60
|
const handleDateTimeChange = useCallback(
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Format } from '@dxos/echo';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { translations } from '#translations';
|
|
13
|
+
|
|
14
|
+
import { TestLayout } from '../../../../../testing';
|
|
15
|
+
import { Form } from '../../../Form';
|
|
16
|
+
|
|
17
|
+
const schema = Schema.Struct({
|
|
18
|
+
location: Format.GeoPoint.annotations({ title: 'Location' }),
|
|
19
|
+
}).pipe(Schema.mutable);
|
|
20
|
+
|
|
21
|
+
type Values = Schema.Schema.Type<typeof schema>;
|
|
22
|
+
|
|
23
|
+
const DefaultStory = () => {
|
|
24
|
+
const [values, setValues] = useState<Values>({ location: [-74.006, 40.7128] });
|
|
25
|
+
return (
|
|
26
|
+
<TestLayout json={values}>
|
|
27
|
+
<Form.Root
|
|
28
|
+
schema={schema}
|
|
29
|
+
values={values}
|
|
30
|
+
onValuesChanged={(values) => setValues((prev) => ({ ...prev, ...values }))}
|
|
31
|
+
>
|
|
32
|
+
<Form.Viewport>
|
|
33
|
+
<Form.Content>
|
|
34
|
+
<Form.FieldSet />
|
|
35
|
+
</Form.Content>
|
|
36
|
+
</Form.Viewport>
|
|
37
|
+
</Form.Root>
|
|
38
|
+
</TestLayout>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const meta = {
|
|
43
|
+
title: 'ui/react-ui-form/FormField/GeoPointField',
|
|
44
|
+
render: DefaultStory,
|
|
45
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
46
|
+
parameters: { layout: 'fullscreen', translations },
|
|
47
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
48
|
+
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = {};
|
|
@@ -9,8 +9,9 @@ import { Input, useTranslation } from '@dxos/react-ui';
|
|
|
9
9
|
import { safeParseFloat } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { translationKey } from '#translations';
|
|
12
|
+
import { type FormFieldRendererProps } from '#types';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import { FormFieldLabel } from '../../FormFieldWrapper';
|
|
14
15
|
|
|
15
16
|
export const GeoPointField = ({
|
|
16
17
|
type,
|
|
@@ -22,7 +23,7 @@ export const GeoPointField = ({
|
|
|
22
23
|
getValue,
|
|
23
24
|
onValueChange,
|
|
24
25
|
onBlur,
|
|
25
|
-
}:
|
|
26
|
+
}: FormFieldRendererProps<GeoPoint>) => {
|
|
26
27
|
const { t } = useTranslation(translationKey);
|
|
27
28
|
const { status, error } = getStatus();
|
|
28
29
|
const geoPoint = useMemo<GeoPoint>(() => getValue() ?? [0, 0], [getValue]);
|
|
@@ -61,7 +62,7 @@ export const GeoPointField = ({
|
|
|
61
62
|
return (
|
|
62
63
|
<Input.Root validationValence={status}>
|
|
63
64
|
{layout !== 'inline' && (
|
|
64
|
-
<FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath}
|
|
65
|
+
<FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} standalone />
|
|
65
66
|
)}
|
|
66
67
|
{layout === 'static' ? (
|
|
67
68
|
<LatLng {...value} />
|
package/src/components/Form/{fields → FormField/fields/MarkdownField}/MarkdownField.stories.tsx
RENAMED
|
@@ -16,20 +16,20 @@ import { Text } from '@dxos/schema';
|
|
|
16
16
|
|
|
17
17
|
import { translations } from '#translations';
|
|
18
18
|
|
|
19
|
-
import { TestLayout } from '
|
|
20
|
-
import { Form } from '
|
|
19
|
+
import { TestLayout } from '../../../../../testing';
|
|
20
|
+
import { Form } from '../../../Form';
|
|
21
21
|
|
|
22
22
|
//
|
|
23
23
|
// String-backed markdown.
|
|
24
24
|
//
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const TestSchema = Schema.Struct({
|
|
27
27
|
notes: Schema.String.pipe(Format.FormatAnnotation.set(Format.TypeFormat.Markdown)).annotations({ title: 'Notes' }),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const StringStory = () => (
|
|
31
31
|
<TestLayout>
|
|
32
|
-
<Form.Root schema={
|
|
32
|
+
<Form.Root schema={TestSchema} defaultValues={{ notes: '# Hello\n\nMarkdown text *here*.' }}>
|
|
33
33
|
<Form.Viewport>
|
|
34
34
|
<Form.Content>
|
|
35
35
|
<Form.FieldSet />
|
|
@@ -111,7 +111,7 @@ const EmptyRefStory = () => {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
const meta = {
|
|
114
|
-
title: 'ui/react-ui-form/MarkdownField',
|
|
114
|
+
title: 'ui/react-ui-form/FormField/MarkdownField',
|
|
115
115
|
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
116
116
|
parameters: {
|
|
117
117
|
layout: 'fullscreen',
|
|
@@ -134,7 +134,7 @@ export const StringBacked: Story = {
|
|
|
134
134
|
export const StringBackedKeepsFocus: Story = {
|
|
135
135
|
render: () => (
|
|
136
136
|
<TestLayout>
|
|
137
|
-
<Form.Root schema={
|
|
137
|
+
<Form.Root schema={TestSchema} defaultValues={{ notes: '' }}>
|
|
138
138
|
<Form.Viewport>
|
|
139
139
|
<Form.Content>
|
|
140
140
|
<Form.FieldSet />
|
|
@@ -13,8 +13,9 @@ import { Text } from '@dxos/schema';
|
|
|
13
13
|
import { createDataExtensions } from '@dxos/ui-editor';
|
|
14
14
|
|
|
15
15
|
import { translationKey } from '#translations';
|
|
16
|
+
import { type FormFieldRendererProps } from '#types';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { FormFieldLabel } from '../../FormFieldWrapper';
|
|
18
19
|
|
|
19
20
|
const editorClassNames =
|
|
20
21
|
'transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2';
|
|
@@ -37,7 +38,7 @@ export const MarkdownField = ({
|
|
|
37
38
|
getStatus,
|
|
38
39
|
getValue,
|
|
39
40
|
onValueChange,
|
|
40
|
-
}:
|
|
41
|
+
}: FormFieldRendererProps) => {
|
|
41
42
|
const { status, error } = getStatus();
|
|
42
43
|
const isRef = Ref.isRefType(type);
|
|
43
44
|
const value = getValue();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
|
|
11
|
+
import { translations } from '#translations';
|
|
12
|
+
|
|
13
|
+
import { TestLayout } from '../../../../../testing';
|
|
14
|
+
import { Form } from '../../../Form';
|
|
15
|
+
|
|
16
|
+
const schema = Schema.Struct({
|
|
17
|
+
count: Schema.Number.annotations({ title: 'Count' }),
|
|
18
|
+
}).pipe(Schema.mutable);
|
|
19
|
+
|
|
20
|
+
type Values = Schema.Schema.Type<typeof schema>;
|
|
21
|
+
|
|
22
|
+
const DefaultStory = () => {
|
|
23
|
+
const [values, setValues] = useState<Values>({ count: 42 });
|
|
24
|
+
return (
|
|
25
|
+
<TestLayout json={values}>
|
|
26
|
+
<Form.Root
|
|
27
|
+
schema={schema}
|
|
28
|
+
values={values}
|
|
29
|
+
onValuesChanged={(values) => setValues((prev) => ({ ...prev, ...values }))}
|
|
30
|
+
>
|
|
31
|
+
<Form.Viewport>
|
|
32
|
+
<Form.Content>
|
|
33
|
+
<Form.FieldSet />
|
|
34
|
+
</Form.Content>
|
|
35
|
+
</Form.Viewport>
|
|
36
|
+
</Form.Root>
|
|
37
|
+
</TestLayout>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const meta = {
|
|
42
|
+
title: 'ui/react-ui-form/FormField/NumberField',
|
|
43
|
+
render: DefaultStory,
|
|
44
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
45
|
+
parameters: { layout: 'fullscreen', translations },
|
|
46
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
47
|
+
|
|
48
|
+
export default meta;
|
|
49
|
+
|
|
50
|
+
type Story = StoryObj<typeof meta>;
|
|
51
|
+
|
|
52
|
+
export const Default: Story = {};
|
|
@@ -2,12 +2,33 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
5
7
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
8
|
|
|
7
9
|
import { Input, type TextInputProps } from '@dxos/react-ui';
|
|
8
10
|
import { safeParseFloat } from '@dxos/util';
|
|
9
11
|
|
|
10
|
-
import { type
|
|
12
|
+
import { type FormFieldRendererProps } from '#types';
|
|
13
|
+
|
|
14
|
+
import { FormFieldWrapper } from '../../FormFieldWrapper';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Extracts numeric `minimum`/`maximum` bounds from a Refinement AST's JSON schema annotation
|
|
18
|
+
* (e.g. produced by Schema.between). Returns undefined when no bounds are declared.
|
|
19
|
+
*/
|
|
20
|
+
const getRefinementBounds = (ast: SchemaAST.AST): { min?: number; max?: number } => {
|
|
21
|
+
if (!SchemaAST.isRefinement(ast)) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const jsonSchema = Option.getOrUndefined(SchemaAST.getJSONSchemaAnnotation(ast));
|
|
25
|
+
if (jsonSchema == null) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
const min = 'minimum' in jsonSchema && typeof jsonSchema.minimum === 'number' ? jsonSchema.minimum : undefined;
|
|
29
|
+
const max = 'maximum' in jsonSchema && typeof jsonSchema.maximum === 'number' ? jsonSchema.maximum : undefined;
|
|
30
|
+
return { min, max };
|
|
31
|
+
};
|
|
11
32
|
|
|
12
33
|
export const NumberField = ({
|
|
13
34
|
type,
|
|
@@ -17,7 +38,9 @@ export const NumberField = ({
|
|
|
17
38
|
onValueChange,
|
|
18
39
|
onBlur,
|
|
19
40
|
...props
|
|
20
|
-
}:
|
|
41
|
+
}: FormFieldRendererProps<number>) => {
|
|
42
|
+
const { min, max } = getRefinementBounds(type);
|
|
43
|
+
|
|
21
44
|
// Track raw string input so the user can clear the field before typing a new number.
|
|
22
45
|
// We only commit to onValueChange when the raw string parses to a valid number.
|
|
23
46
|
const [raw, setRaw] = useState<string>(() => {
|
|
@@ -67,6 +90,8 @@ export const NumberField = ({
|
|
|
67
90
|
disabled={!!readonly}
|
|
68
91
|
placeholder={placeholder}
|
|
69
92
|
value={raw}
|
|
93
|
+
min={min}
|
|
94
|
+
max={max}
|
|
70
95
|
onChange={handleChange}
|
|
71
96
|
onBlur={handleBlur}
|
|
72
97
|
/>
|
|
@@ -14,8 +14,9 @@ import { Button, Icon, Input, useTranslation } from '@dxos/react-ui';
|
|
|
14
14
|
|
|
15
15
|
import { translationKey } from '#translations';
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { omitId } from '../../../../../util';
|
|
18
|
+
import { FormContent, FormFieldSet, FormRoot } from '../../../FormControls';
|
|
19
|
+
import { FormFieldLabel } from '../../FormFieldWrapper';
|
|
19
20
|
import { type RefFieldProps } from './RefField';
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -129,10 +130,10 @@ const InlineForm = ({ reference, db, readonly, useType = defaultUseType }: Inlin
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
return (
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
<
|
|
135
|
-
</
|
|
136
|
-
</
|
|
133
|
+
<FormRoot db={db} schema={formSchema} defaultValues={defaultValues as any} onValuesChanged={handleChange}>
|
|
134
|
+
<FormContent>
|
|
135
|
+
<FormFieldSet collapsible readonly={readonly} />
|
|
136
|
+
</FormContent>
|
|
137
|
+
</FormRoot>
|
|
137
138
|
);
|
|
138
139
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Annotation, Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
11
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
|
|
14
|
+
import { translations } from '#translations';
|
|
15
|
+
|
|
16
|
+
import { Organization, TestLayout } from '../../../../../testing';
|
|
17
|
+
import { Form } from '../../../Form';
|
|
18
|
+
|
|
19
|
+
// Picker: select an existing Organization.
|
|
20
|
+
const RefSchema = Schema.Struct({
|
|
21
|
+
employer: Ref.Ref(Organization).annotations({ title: 'Employer' }),
|
|
22
|
+
}).pipe(Schema.mutable);
|
|
23
|
+
|
|
24
|
+
// Inline: edit the referenced Organization's fields in a nested form.
|
|
25
|
+
const InlineSchema = Schema.Struct({
|
|
26
|
+
employer: Ref.Ref(Organization).pipe(
|
|
27
|
+
Schema.annotations({ title: 'Employer' }),
|
|
28
|
+
Annotation.FormInlineAnnotation.set(true),
|
|
29
|
+
),
|
|
30
|
+
}).pipe(Schema.mutable);
|
|
31
|
+
|
|
32
|
+
const RefStory = ({ schema }: { schema: Schema.Schema<any> }) => {
|
|
33
|
+
const spaces = useSpaces();
|
|
34
|
+
const space = spaces[0];
|
|
35
|
+
const [values, setValues] = useState<Record<string, unknown>>({});
|
|
36
|
+
if (!space) {
|
|
37
|
+
return <Loading />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<TestLayout json={values}>
|
|
42
|
+
<Form.Root
|
|
43
|
+
schema={schema}
|
|
44
|
+
values={values}
|
|
45
|
+
db={space.db}
|
|
46
|
+
onValuesChanged={(values) => setValues((prev) => ({ ...prev, ...values }))}
|
|
47
|
+
// `name` is required; the inline create starts from `{}`, so seed a default the form can then edit.
|
|
48
|
+
onCreate={(_type, props: any) => space.db.add(Obj.make(Organization, { name: 'New organization', ...props }))}
|
|
49
|
+
>
|
|
50
|
+
<Form.Viewport>
|
|
51
|
+
<Form.Content>
|
|
52
|
+
<Form.FieldSet />
|
|
53
|
+
</Form.Content>
|
|
54
|
+
</Form.Viewport>
|
|
55
|
+
</Form.Root>
|
|
56
|
+
</TestLayout>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const meta = {
|
|
61
|
+
title: 'ui/react-ui-form/FormField/RefField',
|
|
62
|
+
render: RefStory,
|
|
63
|
+
decorators: [
|
|
64
|
+
withTheme(),
|
|
65
|
+
withLayout({ layout: 'fullscreen' }),
|
|
66
|
+
withClientProvider({
|
|
67
|
+
createIdentity: true,
|
|
68
|
+
createSpace: true,
|
|
69
|
+
types: [Organization],
|
|
70
|
+
onCreateSpace: ({ space }) => {
|
|
71
|
+
Array.from({ length: 8 }).forEach((_, i) =>
|
|
72
|
+
space.db.add(Obj.make(Organization, { name: `Organization ${i}` })),
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
parameters: {
|
|
78
|
+
layout: 'fullscreen',
|
|
79
|
+
translations,
|
|
80
|
+
},
|
|
81
|
+
} satisfies Meta<typeof RefStory>;
|
|
82
|
+
|
|
83
|
+
export default meta;
|
|
84
|
+
|
|
85
|
+
type Story = StoryObj<typeof meta>;
|
|
86
|
+
|
|
87
|
+
export const Default: Story = {
|
|
88
|
+
args: {
|
|
89
|
+
schema: RefSchema,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Inline: Story = {
|
|
94
|
+
args: {
|
|
95
|
+
schema: InlineSchema,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { type RefOption } from '
|
|
7
|
+
import { type RefOption } from '#types';
|
|
8
|
+
|
|
8
9
|
import { findRefOption } from './RefField';
|
|
9
10
|
|
|
10
11
|
// Sample qualified self URIs as produced by an in-space object (Entity.getURI / `echo://<space>/<id>`).
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import '@dxos/lit-ui/dx-tag-picker.pcss';
|
|
8
|
-
import {
|
|
8
|
+
import { Entity, Filter, Obj, Query, Ref, Scope, Type } from '@dxos/echo';
|
|
9
9
|
import { useQuery, useType as defaultUseType } from '@dxos/echo-react';
|
|
10
10
|
import { ANY_OBJECT_TYPENAME, ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/internal';
|
|
11
11
|
import { SchemaEx } from '@dxos/effect';
|
|
@@ -15,10 +15,11 @@ import { Button, Icon, Input, useTranslation } from '@dxos/react-ui';
|
|
|
15
15
|
import { ParentLabelAnnotationId } from '@dxos/schema';
|
|
16
16
|
|
|
17
17
|
import { translationKey } from '#translations';
|
|
18
|
+
import { type CreateOptions, type FormFieldRendererProps, type RefFieldDataProps, type RefOption } from '#types';
|
|
18
19
|
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { omitHiddenFormFields, omitId } from '../../../../../util';
|
|
21
|
+
import { ObjectPicker } from '../../../../ObjectPicker';
|
|
22
|
+
import { FormFieldLabel } from '../../FormFieldWrapper';
|
|
22
23
|
|
|
23
24
|
// TODO(burdon): Factor out.
|
|
24
25
|
const isRefSnapshot = (val: any): val is { '/': string } => {
|
|
@@ -89,27 +90,7 @@ const defaultUseResults: NonNullable<RefFieldProps['useResults']> = (db, typenam
|
|
|
89
90
|
Query.select(Filter.type(DXN.make(typename))).from(Scope.space(), Scope.registry()),
|
|
90
91
|
);
|
|
91
92
|
|
|
92
|
-
export type RefFieldProps =
|
|
93
|
-
Pick<
|
|
94
|
-
ObjectPickerContentProps,
|
|
95
|
-
'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap'
|
|
96
|
-
> & {
|
|
97
|
-
db?: Database.Database;
|
|
98
|
-
// TODO(burdon): Replace hooks with callbacks.
|
|
99
|
-
useType?: (db?: Database.Database, typeUri?: URI.URI) => Type.AnyEntity;
|
|
100
|
-
useResults?: (db?: Database.Database, typename?: string) => Entity.Any[];
|
|
101
|
-
getOptions?: (
|
|
102
|
-
objects: Entity.Any[],
|
|
103
|
-
options?: { parentLabel?: boolean; getTypePlaceholder?: (typename: string) => string },
|
|
104
|
-
) => RefOption[];
|
|
105
|
-
/**
|
|
106
|
-
* Persist a newly-created object. Called after the user fills out the
|
|
107
|
-
* inline create form and clicks Save. Should add the object to the
|
|
108
|
-
* database and return it (sync or async). The returned object is then
|
|
109
|
-
* wired into this slot's form value as a Ref.
|
|
110
|
-
*/
|
|
111
|
-
onCreate?: (schema: Type.AnyEntity, values: any) => Obj.Unknown | Promise<Obj.Unknown> | undefined | void;
|
|
112
|
-
};
|
|
93
|
+
export type RefFieldProps = FormFieldRendererProps & RefFieldDataProps & CreateOptions;
|
|
113
94
|
|
|
114
95
|
export const RefField = (props: RefFieldProps) => {
|
|
115
96
|
const {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
|
|
11
|
+
import { translations } from '#translations';
|
|
12
|
+
|
|
13
|
+
import { TestLayout } from '../../../../../testing';
|
|
14
|
+
import { Form } from '../../../Form';
|
|
15
|
+
|
|
16
|
+
// A literal union auto-dispatches to SelectField.
|
|
17
|
+
const schema = Schema.Struct({
|
|
18
|
+
status: Schema.Literal('active', 'inactive', 'archived').annotations({ title: 'Status' }),
|
|
19
|
+
}).pipe(Schema.mutable);
|
|
20
|
+
|
|
21
|
+
type Values = Schema.Schema.Type<typeof schema>;
|
|
22
|
+
|
|
23
|
+
const DefaultStory = () => {
|
|
24
|
+
const [values, setValues] = useState<Values>({ status: 'active' });
|
|
25
|
+
return (
|
|
26
|
+
<TestLayout json={values}>
|
|
27
|
+
<Form.Root
|
|
28
|
+
schema={schema}
|
|
29
|
+
values={values}
|
|
30
|
+
onValuesChanged={(values) => setValues((prev) => ({ ...prev, ...values }))}
|
|
31
|
+
>
|
|
32
|
+
<Form.Viewport>
|
|
33
|
+
<Form.Content>
|
|
34
|
+
<Form.FieldSet />
|
|
35
|
+
</Form.Content>
|
|
36
|
+
</Form.Viewport>
|
|
37
|
+
</Form.Root>
|
|
38
|
+
</TestLayout>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const meta = {
|
|
43
|
+
title: 'ui/react-ui-form/FormField/SelectField',
|
|
44
|
+
render: DefaultStory,
|
|
45
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
46
|
+
parameters: { layout: 'fullscreen', translations },
|
|
47
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
48
|
+
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = {};
|
|
@@ -7,9 +7,11 @@ import React, { useCallback } from 'react';
|
|
|
7
7
|
import { Icon, Input, Select, type SelectRootProps } from '@dxos/react-ui';
|
|
8
8
|
import { getStyles } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
|
-
import { type
|
|
10
|
+
import { type FormFieldRendererProps } from '#types';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import { FormFieldLabel } from '../../FormFieldWrapper';
|
|
13
|
+
|
|
14
|
+
export type SelectFieldOptions = FormFieldRendererProps & {
|
|
13
15
|
options?: Array<{ value: string | number; label?: string; secondaryLabel?: string; icon?: string; iconHue?: string }>;
|
|
14
16
|
};
|
|
15
17
|
|
|
@@ -11,11 +11,11 @@ import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
|
11
11
|
|
|
12
12
|
import { translations } from '#translations';
|
|
13
13
|
|
|
14
|
-
import { TestLayout } from '
|
|
15
|
-
import { Form } from '
|
|
14
|
+
import { TestLayout } from '../../../../../testing';
|
|
15
|
+
import { Form } from '../../../Form';
|
|
16
16
|
import { SelectOptionField } from './SelectOptionField';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const TestSchema = Schema.Struct({
|
|
19
19
|
options: Schema.Array(SelectOption).pipe(Schema.mutable),
|
|
20
20
|
}).pipe(Schema.mutable);
|
|
21
21
|
|
|
@@ -32,7 +32,7 @@ const DefaultStory = () => {
|
|
|
32
32
|
return (
|
|
33
33
|
<TestLayout>
|
|
34
34
|
<Form.Root
|
|
35
|
-
schema={
|
|
35
|
+
schema={TestSchema}
|
|
36
36
|
values={values}
|
|
37
37
|
fieldMap={{ options: SelectOptionField }}
|
|
38
38
|
onSave={(values) => setValues(values)}
|
|
@@ -49,7 +49,7 @@ const DefaultStory = () => {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const meta = {
|
|
52
|
-
title: 'ui/react-ui-form/SelectOptionField',
|
|
52
|
+
title: 'ui/react-ui-form/FormField/SelectOptionField',
|
|
53
53
|
component: SelectOptionField as any,
|
|
54
54
|
render: DefaultStory,
|
|
55
55
|
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|