Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Request: Supports custom status types

Open br14n-sol opened this issue 1 year ago • 3 comments

We should be able to pass our own state type to usePrefix as in the case of makeTheme.

This would be especially useful for those that use a state other than the one defined by inquirer, as in my case with inquirer-file-selector, which uses a state of its own to define when the user cancels the prompt.

br14n-sol avatar Oct 14 '24 18:10 br14n-sol

That's a reasonable request. PR welcomed is anyone gets to it before I do.

SBoudrias avatar Oct 15 '24 19:10 SBoudrias

@br14n-sol @SBoudrias I would like to work on this but there are a few doubts that I have:

  1. There is some logic written on the loading state, what will happen to it if we start allowing users to define custom logic?
  2. I am understanding that if the user have passed custom states, then he needs to pass some fn is args which will return true/false for loading state

malavshah9 avatar Oct 19 '24 18:10 malavshah9

Hey @malavshah9 👋🏻 Unknown state would try to get theme.prefix[status] for their prefix; we might want to add a fallback to idle on unknown and undefined prefix icons.

Also, make sure we maintain the TS auto-suggestions to propose known values in the editor. I forgot exactly, but there's a trick to not replace the type with string autocomplete suggestion.

SBoudrias avatar Oct 19 '24 18:10 SBoudrias