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

Additional Field Types #61

Open
wesen opened this issue Dec 14, 2023 · 7 comments
Open

Additional Field Types #61

wesen opened this issue Dec 14, 2023 · 7 comments

Comments

@wesen
Copy link

wesen commented Dec 14, 2023

I have a framework to describe application's input parameters in YAML, and use that to generate CLI flags/REST endpoints/HTML forms and much more, and I was about to write a TUI widget to render them with bubbletea. Here are a list of the widgets I need to build to support my tool:

  • checkbox
  • integer/float/string/bool lists
  • date
  • file/multi-file select
  • key value entry

I was wondering if you had any plans to implement these (and thus a design in mind), or if I should just go ahead and build my own and keep them say, in a separate library?

Here's a proof of concept: https://asciinema.org/a/ndG2OO2XqjYtenE5x9LYLRKvh

Here's my framework: https://github.com/go-go-golems/glazed

@maaslalani
Copy link
Member

Date and File selects are definitely on the roadmap (no eta yet).

I'm curious what you expect checkboxes to look like? Perhaps they can be tweaked by the theme to get the style you want on a multi-select list. Maybe we can implement this as an alternative view on NewConfirm or its own field NewCheckbox.

integer/float/string/bool lists should be implemented on select and multi-selects by simply changing the generic type: see the the following example (which uses a custom enum and can be swapped for any type)

https://github.com/charmbracelet/huh/blob/main/examples/burger/main.go#L106-L112

@wesen
Copy link
Author

wesen commented Dec 14, 2023

good idea on doing checkboxes with a multiselect list!

The lists I am talking about are dynamic, in that people can enter say, product ids, or a list of prices. I am using these forms mostly as search forms for ecommerce queries right now.

@maaslalani
Copy link
Member

I think we can consider adding lists as well, for now I would highly recommend using a NewText and allowing the user to enter each item on a new line or a NewInput and having the lists comma separated.

I think the UX of a list could be quite better since then you could dynamically display them and validate each item so we can consider adding it, it would also make editing for the user easier as they could delete items very easily.

@wesen
Copy link
Author

wesen commented Dec 14, 2023

Yeah, that is a good first option, and I am not sure yet either what widget would work for me. Anyway, it's easy to add fields in my own package, it'll give you an opportunity to pick and choose.

@WTIGER001
Copy link

Also it would be nice to have "select" that operates like the confirm. with the buttons.

@maaslalani
Copy link
Member

Also it would be nice to have "select" that operates like the confirm. with the buttons.

We've added an Inline option for Select which does something along these lines, not with buttons but rather with a horizontally scrolling options list with one option displayed at a time.

@maaslalani
Copy link
Member

Just an update on this issue, FilePicker field was added to Huh?!

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

3 participants