First Lit & Friends Community Call! #2986
Replies: 6 comments 3 replies
-
Hi guys! Great idea! :D I don't know if I'll make it in time, so just in case, I'll leave here a summary of my other discussion about forms :) A new package for Forms?It'd be great to have a dedicated package for forms. Some of the features it could have:
Forms handling comes in many flavors depending on the framework or the library: which way should we choose? 1. Template-drivenWith this variation, the source of truth would be the template itself, but with additional info stored in a Controller (or Directives?). This approach would be similar to React Hook Form. With this approach, it's the template that dictates whether or not to add a field to the model. Example: form = new Form<User>(this, {
... // config
}); <form>
<input type="text" ${this.form.bind('name')}>
<input type="text" ${this.form.bind('surname')}>
<button>submit</button>
</form>
<!-- Or perhaps even... -->
<form ${this.form.bind()}>
<input type="text" name="name">
<input type="text" name="surname">
<button>submit</button>
</form> Accessing/Manipulating the form: // Properties
this.form.value
this.form.dirtyFields
this.form.touchedFields
this.form.blurredFields
this.form.disabledFields
// Methods
this.form.setField(key, value);
this.form.patchValue(partialFormValue);
this.form.reset(key?);
this.form.setDirty(key, isDirty);
this.form.setTouched(key, isTouched);
this.form.setBlurred(key, isBlurred);
this.form.disable(key);
this.form.enable(key);
this.form.valueChanges(key?): Observable Advantages:
Disadvantages:
2. Model-drivenWith this approach, the source of truth is the model and we just bind our controls to existing fields. form = new Form<User>(this, {
// Mandatory!
defaultValues: {
name: '',
surname: ''
}
... // config
}); <form>
<input type="text" ${this.form.bind('name')}>
<input type="text" ${this.form.bind('surname')}>
<!-- Error! TypeScript will tell us there's no "city" -->
<input type="text" ${this.form.bind('city')}>
<button>submit</button>
</form> Advantages:
Disadvantages:
3: Model-driven, with explicit APIWith this approach, we accurately describe the shape of our forms with appropriate APIs. It'd be inspired by Angular's Reactive Forms. fb = new FormBuilder(this);
// Could be made easier if all we want is a control with a default value, like: `name: 'Michele'`
form = this.fb.group({
user: this.fb.group({
name: this.fb.control('Michele'),
surname: this.fb.control('Stieven'),
gender: this.fb.control<'M' | 'F'>('M'),
}),
agreement: this.fb.control(false),
phones: this.fb.array<FormControl<string>>(),
addresses: this.fb.array<FormGroup<{
street: FormControl<string>
nr: FormControl<string>
}>>()
}); Advantages:
Disadvantages:
SummaryThe team should decide if:
My personal favorite is of course the last one but I get it if it's too divergent from standards: if so, it'd be great to have a 3rd party lib (maybe without the RxJS dependency), I'm not a library author and I don't have the time (and experience) to maintain one, I put together some code to make sure it's viable but I pretty much stop here. Also there are points which should be discussed that I don't feel comfortable deciding for myself, such as:
It's a hard topic which I think could be best discussed by the team of great minds behind Lit :) |
Beta Was this translation helpful? Give feedback.
-
I would be interesting in hearing more about the integration of lit components into different frameworks like react, svelte etc. What is the best way to do that? What things to consider? (E.g. I am experiencing an issue where components are mounted slightly later to my sveltekit app causing layout shifts since I am loading them async (not doing that leads to a window not defined reference error)) |
Beta Was this translation helpful? Give feedback.
-
We've talked on the Lit team a bit about whether we should start up an RFC process. It'd be great to hear thoughts on this from people! |
Beta Was this translation helpful? Give feedback.
-
Thanks everyone who joined! We had over 50 callers on our first call, wow!! We'll schedule the next call soon, probably for about a month from now. Hopefully we'll have some updates on an RFC process, and we'll try to poll the community to see what the best times are for everyone too. |
Beta Was this translation helpful? Give feedback.
-
Posting a slightly cleaned up version of minutes from the meeting today. We'll aim to take better notes in future calls!
|
Beta Was this translation helpful? Give feedback.
-
Any chance of a VOD? |
Beta Was this translation helpful? Give feedback.
-
Hello friends,
We're excited to announce our first ever Lit & Friends Community Call next Thursday 6/9 at 9:30am PDT on Google Meet! Please join members of the Lit team to talk about all things Lit and web components.
Agenda
As this is our first community call, we don't have a set agenda yet. We may discuss recurring agenda items and overall structure at the first few calls. If you want to discuss something specific, please add the idea in a comment below.
Topics don't need to be limited to Lit, though they should be relevant. They may include web component standards, tooling such as Open WC, and more. We will prioritize existing open issues, pull requests, and discussions in the Lit repo, and address other topics time-permitting.
Info
Lit Community Call
Thursday, June 9 · 9:30 – 10:30am
Google Meet joining info
Video call link: https://meet.google.com/zas-osqa-rmi
Or dial: (US) +1 253-289-7019 PIN: 155 520 209 14#
More phone numbers: https://tel.meet/zas-osqa-rmi?pin=7351877644603
Code of Conduct
This call is covered by our Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions