clack icon indicating copy to clipboard operation
clack copied to clipboard

feat(@clack/core,@clack/prompts): multiline support

Open Mist3rBru opened this issue 1 year ago • 10 comments

Multiline Support

Support multiline texts either with \n, or long ones that exceed terminal width, without breaking the layout

List of supported prompts:

  • [x] text
  • [x] password
  • [ ] confirm
    • Is just yes/no
  • [x] select
  • [ ] selectKey
    • It was made to handle short options
  • [x] multiselect
  • [ ] groupMultiselect
    • It was made to handle short options
  • [x] note
  • [x] intro
  • [x] cancel
  • [x] outro
  • [x] log
  • [x] spinner

Continuation of #141

Closes #101 Closes #132 Relates #135 #111 #35

Mist3rBru avatar Aug 14 '23 17:08 Mist3rBru

🦋 Changeset detected

Latest commit: 5d3030b9d9c1daf87d875819ad1bb0c2f4fbc5d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Minor
@clack/core Minor

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

changeset-bot[bot] avatar Aug 14 '23 17:08 changeset-bot[bot]

@cpreston321 @natemoo-re take a look on this version, this would be my approach to implement multi line support on core

Mist3rBru avatar Aug 14 '23 17:08 Mist3rBru

Hey @cpreston321 @natemoo-re, I created a subpath themes on core, that exports a defaultTheme function and our Symbols that are implemented by prompts, this can be used to create more themes, and it is also helpful for people that wants to extend core with a starting point out of the box. Then I implemented this theme on prompts with our previous alterations.

If you agree with these alterations, we can create a doc on how to create a theme, then furthermore use these themes as options on promps

I hope you enjoy it!

Mist3rBru avatar Aug 18 '23 18:08 Mist3rBru

@Mist3rBru I am starting to like this. The only thing is core should have the utility function to create the theme and @clack/prompt should create that theme using that helper. Another option is to create another package called @clack/themes that has different themes and presets that @clack/prompts consume.

I think core should hold core functionality so people can tweak there own. @clack/prompts has it's unique theme.

What do you think? @Mist3rBru

cpreston321 avatar Aug 21 '23 13:08 cpreston321

@cpreston321 my goal with defaultTheme was to somehow prove that it is possible to create a theme with format method.

The only thing is core should have the utility function to create the theme and @clack/prompt should create that theme using that helper.

I think core should hold core functionality so people can tweak there own. @clack/prompts has it's unique theme.

Thinking this way, we will not provide theme options, neither on core or prompts, since people can create their own.

Another option is to create another package called @clack/themes that has different themes and presets that @clack/prompts consume.

That would be the ideal, but since this PR is focused on multiline suport, it should be made on other PR, with more options, to not mix things.

For now we can keep it simple, only moving this theme to prompts, stick with this format method, and track these themes on other PR.

Mist3rBru avatar Aug 21 '23 14:08 Mist3rBru

@cpreston321 changes have been applied, changeset is included. When you are ready, it can be merged.

Thank you very much for your support! I am glad to contribute 😄.

Mist3rBru avatar Aug 21 '23 15:08 Mist3rBru

Hey @Mist3rBru! I am still seeing some weirdness with multiline on password. Think you can check it out? Once we fine tune this. I will ping nate for feedback. Then hopefully get this merged in 🙏🏼

https://github.com/natemoo-re/clack/assets/6619884/98f8bb76-802c-49fd-b69a-7455384d0243

cpreston321 avatar Aug 24 '23 20:08 cpreston321

@cpreston321 I updated the strLength function to handle these unicode, ansi and color chars, now it must not happen again.

Mist3rBru avatar Aug 24 '23 23:08 Mist3rBru

This will be a huge improvement! @cpreston321 @natemoo-re - if you could please review and merge it'd be much appreciated.

mazshakibaii avatar Sep 15 '23 11:09 mazshakibaii

I would hugely value this too 🙋

steve8708 avatar Jun 02 '24 17:06 steve8708