Initial RDF forms component#798
Conversation
Prompt: reading the RDFinput file, pls make suggestions of how to impprve the code to make it easier to follow and read. I beliebe it is difficult to follow the fact that one has a rdf forms subject and a data subject as well and how it is all itertwinded. Co-Authored-By: GitHub Copilot (raptor-mini) <copilot@github.com>
NoelDeMartin
left a comment
There was a problem hiding this comment.
Added a few initial comments, mostly regarding a11y and component architecture.
| rdfTurtleFormatSource=${rdfTurtleFormatSource} | ||
| rdfURI=${rdfURI} | ||
| whichForm=${whichForm} | ||
| rdfName=${rdfName} | ||
| subjectTurtleFormatSource=${subjectTurtleFormatSource} | ||
| subjectName=${subjectName} | ||
| subjectURI=${subjectURI}> |
There was a problem hiding this comment.
Do we need all these attributes? This is a bit confusing, I'm not sure what each property does and why we need so many.
Could it work with something like this?
<solid-ui-rdf-form
form="https://solidos.solidcommunity.net/public/2021/solidUiFormTestData/dummyFormTestFile.ttl#form"
subject="https://solidos.solidcommunity.net/public/2021/alice.ttl#me"
>
</solid-ui-rdf-form>Internally, it could resolve the form and subject from the store associated to the authenticated user.
| @property({ type: String }) | ||
| set rdfURI (value: string) { |
There was a problem hiding this comment.
I think these two propertie (rdfURI and subjectURI) can probably be simplified a lot, I'm not sure we need the _parsedUrl variables or duplicating the URL parsing code. Check out Lit converters.
| }) | ||
| const me = Namespace(this.subjectURI + '#')(this.whichSubject) | ||
|
|
||
| return html` |
There was a problem hiding this comment.
Other than the inputs, shouldn't this output a native <form> as well? Ideally, whatever is generated from this component ends up being a "real" form. That is important in order to integrate with accessibility tooling and user expectations (implicit form submission, etc.).
| return html` <solid-ui-rdf-input | ||
| .store=${store} | ||
| .formSubject=${sym(part.value)} | ||
| .dataSubject=${me} |
There was a problem hiding this comment.
I think all inputs should also have a name attribute. Otherwise, they'll be ignored by the form (again, important for a11y, etc.).
| @property({ attribute: false }) | ||
| accessor store!: LiveStore |
There was a problem hiding this comment.
Instead of passing the store as a property, I think we should use Lit context instead. See my other comments talking about this.
| export type FieldParamsObject = { | ||
| size?: number, // input element size attribute | ||
| type?: InputType, // input element type attribute. Default: 'text' (not for Comment and Heading) | ||
| element?: string, // element type to use (Comment and Heading only) | ||
| style?: string, // style to use | ||
| dt?: string, // xsd data type for the RDF Literal corresponding to the field value. Default: xsd:string | ||
| defaultInputValue?: string, // e.g. 'mailto:'. Default value in input field, will be removed when displaying actual value to user. | ||
| namedNode?: boolean, // if true, field value corresponds to the URI of an RDF NamedNode. Overrides dt and defaultInputValue. | ||
| pattern?: RegExp // for client-side input validation; field will go red if violated, green if ok | ||
| } |
There was a problem hiding this comment.
Many of these are currently unused, right? I see that this is a WIP, so it's fine. But before merging, I would remove everything that isn't used (you know, YAGNI, removing dead code, etc.).
Also, I'm not sure I like the style config... that goes a bit against the idea of RDF forms, given that different UI libraries may render forms differently, and inline styles are probably not going to work correctly in all of them. But if that was a design decision when creating the RDF forms, ok.
Prompt: can this #sym:HTMLElementTagNameMap be generated automatically from vite-config/ components.ts for all RDF suffixed components? Co-Authored-By: GitHub Copilot (raptor-mini) <copilot@github.com>
|
RDFInput will make use of the new Input components when it is merged: #815 |
|
We need to improve the name property of the generated form and make sure they are unique. |
| @consume({ context: storeContext, subscribe: true }) | ||
| private accessor storeContext: StoreContext = DEFAULT_STORE | ||
|
|
||
| @property({ attribute: false }) |
There was a problem hiding this comment.
is the attribute: false necessary? I guess we do want to observe is this property changes, although it'll be very uncommon (wouldn't even worry about testing it for now).
| private accessor entireDataIsReadonly: boolean = true | ||
|
|
||
| @state() | ||
| private accessor _parsedUrl: URL | null = null |
There was a problem hiding this comment.
I mentioned this in my previous review, but as reminder I don't think we need these two attributes, see Lit converters.
Co-authored-by: Noel De Martin <noel@noeldemartin.com>
This is for now: