Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing new field widgets? #29

Open
josephguillaume opened this issue Mar 10, 2023 · 1 comment
Open

Implementing new field widgets? #29

josephguillaume opened this issue Mar 10, 2023 · 1 comment

Comments

@josephguillaume
Copy link

Just trying to understand the design

The documentation states:
"The field widget, the widget that will be displayed. It may be a dropdown, radios, a map to select a location or something else. You can also implement your own."

If I understand correctly, widgets are exported in https://github.com/danielbeeke/rdf-form/blob/master/src/plugins.ts and loaded as BaseFields in:

Object.assign(this.registeredFieldClasses, BaseFields, event.detail.fields)

event.detail.fields doesn't seem to add anything at this time?

Each widget has to extend https://github.com/danielbeeke/rdf-form/blob/master/src/elements/ElementBase.ts and includes html templates constructed as string literals using uhtml

Implementing a widget therefore involves adding an import to plugins.ts and rebuilding the custom component. (There is no dynamic/runtime widget registration).

Does this sound right? Thanks!

@danielbeeke
Copy link
Owner

It should be possible to do something like this:

const form = document.createElement('rdf-form')
form.addEventListener('register-elements', (event) => {
  event.detail.fields = {
    'my-field': MyField,
    'my-field2': MyField2,
  }
})

It should not be needed to rebuild the custom component.

I am also working on a new iteration of some of the ideas of rdf-form.
You can see it here: https://github.com/danielbeeke/frm
That form system is built upon SHACL. It is no yet finished though.
It is easier to extend because it has a config which you can just give extra widgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants