rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.3k stars 2.19k forks source link

NEW: RJSF version 5 beta released #2956

Closed heath-freenome closed 2 years ago

heath-freenome commented 2 years ago

Here is the 5.x migration guide

Any and all feedback/issues are appreciated

AntonPuko commented 2 years ago

Hi, is there any time estimation when the new major will be released at least with alpha flag? Thnx!

heath-freenome commented 2 years ago

No promises, but best guess is beta in mid-August

benjdlambert commented 2 years ago

@heath-freenome sounds great, is mid-august still a reasonable possibility for v5?

heath-freenome commented 2 years ago

@heath-freenome sounds great, is mid-august still a reasonable possibility for v5?

I'm shooting for releasing 5.0.0-beta.1 before the end of the month. Just wrapping up the documentation and a few small fixes

benjdlambert commented 2 years ago

@heath-freenome awesome - sounds great! Thanks!

kikonejacob commented 2 years ago

congratulation on the release. I'm getting the following error when installing 5.0.0-beta.2: Module not found: Can't resolve '@rjsf/core/dist/components/fields/ArrayField' Apparently, the typescript types are generated but no js files

image
heath-freenome commented 2 years ago

Can you give me an expanded context on where you are seeing this error (in other words what is trying to import from that directory location)? All of the source code was rolled up into the base directory .js files... The `.d.ts` files weren't rolled up, but I'm leaning towards doing that as well in the beta.3 release

Screen Shot 2022-08-29 at 10 26 33 PM
kikonejacob commented 2 years ago

u give me an expanded context on where you are seeing this error (in other words what is trying to import from that directory location)? All of the source code was rolled up into the b

Sounds good. I was getting the error when trying to import ArrayField.

import ArrayField from '@rjsf/core/dist/components/fields/ArrayField';
heath-freenome commented 2 years ago

What are you hoping to do by importing ArrayField? Are you trying to override it or something?

kikonejacob commented 2 years ago

What are you hoping to do by importing ArrayField? Are you trying to override it or something?

Yes. I have a use case where I override ArrayField when needed and just mount ArrayField when not needed. I think the component folder needs to be exposed. UISchema is great but there are use cases where we may need more control.

heath-freenome commented 2 years ago

Yes. I have a use case where I override ArrayField when needed and just mount ArrayField when not needed. I think the component folder needs to be exposed. UISchema is great but there are use cases where we may need more control.

Can you explain your use case? Several more components of ArrayField were exposed in the v5 beta as templates. Maybe your use case has been simplified by those changes?

kikonejacob commented 2 years ago

Yes. I have a use case where I override ArrayField when needed and just mount ArrayField when not needed. I think the component folder needs to be exposed. UISchema is great but there are use cases where we may need more control.

Can you explain your use case? Several more components of ArrayField were exposed in the v5 beta as templates. Maybe your use case has been simplified by those changes?

So I have some properties that are of type array but I want to render/edit them in a text editor (monaco-editor) component. This requires giving full control of the array editing to the component that renders the Monaco editor. It seems to me that the ArrayField has some abstractions that are not needed in this case and can create problems. The array field assumes that each item will be rendered in a list but in this case, the text editor will just handle it differently. The only thing that the editor needs is to the get an array, and pass the array back. For this use case, I have to override ArrayField when the array property requires a text editor and use ArrayField with it is needed.

Is there a way to override ArrayField and still be able to access the original ArrayField without an import? Same question for templates?

heath-freenome commented 2 years ago

You could try calling getDefaultRegistry() and access fields.ArrayField. The same would also work for the templates.

const defaultRegistry = getDefaultRegistry();
const { ArrayField } = defaultRegistry.fields;
heath-freenome commented 2 years ago

@kikonejacob In 5.0.0-beta.7 we added a new field called ArraySchemaField (defaulting to SchemaField) which lets you override the way an array item children is rendered. This is the children prop passed to the ArrayFieldItemTemplate. Now in your specific use case you can override just that ArraySchemaField to modify the name before passing it down to the SchemaField in a manner similar to how you would have accessed the ArrayField itself. Hopefully that simplifies your use case alot

kikonejacob commented 2 years ago

@kikonejacob In 5.0.0-beta.7 we added a new field called ArraySchemaField (defaulting to SchemaField) which lets you override the way an array item children is rendered. This is the children prop passed to the ArrayFieldItemTemplate. Now in your specific use case you can override just that ArraySchemaField to modify the name before passing it down to the SchemaField in a manner similar to how you would have accessed the ArrayField itself. Hopefully that simplifies your use case alot

Thanks. I. will try it out