-
Notifications
You must be signed in to change notification settings - Fork 161
feat: rework values and user input to be separate #334
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
Conversation
🦋 Changeset detectedLatest commit: 831029d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@example/basic • @example/changesets commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i really like this refactor, you're just lacking a changeset and i'm wondering if these changes impact all the examples we've created in the examples dir
dreyfus92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it 🫡
Fixes #330
Basically, this introduces a new
userInputfield and event to the core.The difference is:
userInputtracks what the user has typed in (iftrack: true)valuein the core anymoreThis means it is the responsibility of each prompt to decide what to do with
value. They can then callthis._setValue(value)to set the value and trigger thevalueevent.An example - text prompt
The text prompt wants to set the value to what the user has typed in. So we can simply listen for
userInputand setvalueto whatever they have typed. Or we can wait forfinalizeand do it.A more complex example - auto complete
The auto complete prompt wants to take user input, but this isn't the value. The value should be the completed value.
To achieve this, we can set
valueonly once someone selects an option.This means the
valueis only everundefinedor a selected option.Notable changes
submit(press<RETURN>), it used to run against initial values tooundefined(it always could but we didn't type it as such, iirc)valueas a strong type)