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

Publicize Group Commands PrevField and NextField #175

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

KevM
Copy link
Contributor

@KevM KevM commented Mar 20, 2024

This change makes it possible to create a custom field and support navigation between fields of the group like the built in huh fields do.

Context

I am trying to create my own custom input fields and ran into the private prevField and nextField commands preventing me from behaving like your built-in fields do.

@KevM KevM requested a review from maaslalani as a code owner March 20, 2024 20:10
@KevM KevM changed the title Publicize group.PrevField and group.NextField Publicize Group Commands PrevField and NextField Mar 20, 2024
@ardnew
Copy link
Contributor

ardnew commented Mar 28, 2024

This should fix #108

This change makes it possible to create a custom field and support navigation between fields of the group like the built in huh fields do.
@KevM KevM force-pushed the publicize-next-prev-field branch from b5efce0 to d6ee6fd Compare April 1, 2024 14:45
@KevM
Copy link
Contributor Author

KevM commented Apr 1, 2024

Fixed the merge conflict with main

@WTIGER001
Copy link

I am interested in this too.

@KevM
Copy link
Contributor Author

KevM commented Apr 3, 2024

@maaslalani is there anything I can do to help out with this PR's acceptance? Is it being held because a different (non-command oriented) way to officially move to the next or previous field in the form is being investigated?

@KevM
Copy link
Contributor Author

KevM commented Apr 4, 2024

@bashbunni Howdy! ⛵ This the issue I mentioned in Discord. Happy to do what I can to help.

Copy link
Member

@bashbunni bashbunni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey do you mind providing me with an example of how you're hoping to apply these changes? An example of some custom field that requires the PrevField and NextField functions to be public would be fantastic. I've seen that others are experiencing a similar blocker, but I don't have an example that comes to mind. That would be incredibly helpful.

.vscode/launch.json Outdated Show resolved Hide resolved
@KevM
Copy link
Contributor Author

KevM commented Apr 4, 2024

@bashbunni I pushed a new branch to my fork extending this PR with an example custom field. I didn't want to add it to this PR as it is pretty buggy and not ready for release. Happy to work to fix it up and simplify it if so desired.

Without this PR it is not possible to move to the next form field by issuing a huh.NextField command: like this

@bashbunni
Copy link
Member

@KevM Thank you! The changes make sense to me with that context. I'll wait until Maas is back given that he is the code owner for this project. He may have a chance to review it in the next couple of weeks, feel free to ping me again after the 20th if it hasn't been unblocked by then.

@bashbunni bashbunni added the enhancement New feature or request label Apr 4, 2024
@maaslalani
Copy link
Member

@KevM Thank you so much, this makes sense since it is needed to implement custom fields 👍

@maaslalani maaslalani merged commit e79262f into charmbracelet:main Apr 4, 2024
20 checks passed
@KevM KevM deleted the publicize-next-prev-field branch April 4, 2024 20:19
ardnew pushed a commit to ardnew/huh that referenced this pull request Apr 29, 2024
* Publicize group.PrevField and group.NextField

This change makes it possible to create a custom field and support navigation between fields of the group like the built in huh fields do.

* Remove launch.json which I added by mistake

---------

Co-authored-by: Kevin Miller <kevin@neomantra.net>
renovate bot added a commit to jippi/dottie that referenced this pull request Jun 5, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/charmbracelet/huh](https://togithub.com/charmbracelet/huh)
| `v0.3.0` -> `v0.4.2` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcharmbracelet%2fhuh/v0.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcharmbracelet%2fhuh/v0.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcharmbracelet%2fhuh/v0.3.0/v0.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcharmbracelet%2fhuh/v0.3.0/v0.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[github.com/charmbracelet/lipgloss](https://togithub.com/charmbracelet/lipgloss)
| `v0.10.0` -> `v0.11.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcharmbracelet%2flipgloss/v0.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcharmbracelet%2flipgloss/v0.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcharmbracelet%2flipgloss/v0.10.0/v0.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcharmbracelet%2flipgloss/v0.10.0/v0.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charmbracelet/huh (github.com/charmbracelet/huh)</summary>

###
[`v0.4.2`](https://togithub.com/charmbracelet/huh/releases/tag/v0.4.2)

[Compare
Source](https://togithub.com/charmbracelet/huh/compare/v0.4.1...v0.4.2)

### Your favourite files 📁

Huh? `v0.4.0` (`v0.4.2`) introduces the File Picker to forms ✨

Prompt users to select a file in just a few lines of code, you know the
drill :)

```go
var file string

huh.NewFilePicker().
    Title("Select a file:").
    Description("This will be your profile image.").
    AllowedTypes([]string{".png", ".jpeg", ".webp", ".gif"}).
    Value(&file)
```

<img width="600"
src="https://vhs.charm.sh/vhs-5DCaCK6WfJGCUuWMjTXLrM.gif" alt="Made with
VHS">

***

#### Field Interface

##### Zoom

File pickers introduce a new `Zoom` method to the `Field` interface.

```go
type Field interface {

    // ...

    Zoom() bool

    // ...

}
```

`Zoom` tells the form whether this field should be the only visible
field.

Notice how the `FilePicker` field zooms in when selecting a file and
zooms out when the file is selected, showing only the selected file.

##### Skip

Notes introduce a new `Skip` method to the `Field` interface.

```go
type Field interface {

    // ...

    Skip() bool

    // ...

}
```

Skip indicates to the form whether or not to skip this field, i.e. don't
let the user interact with it. This is useful for notes to be purely
informational.

#### What else?

- feat: set `height` in `WithHeight` by
[@&#8203;ardnew](https://togithub.com/ardnew) in
[charmbracelet/huh#122
- feat: use `EchoMode` for `Input` by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[charmbracelet/huh#131
- feat: zoom `FilePicker` by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/huh#133
- feat: inline `Select` by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/huh#136
- feat: <kbd>ctrl+u</kbd>, <kbd>ctrl+d</kbd>, <kbd>g</kbd>, and
<kbd>G</kbd> keybindings on `Select` by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[charmbracelet/huh#143
- feat: predefined `ValidationFunc`s by
[@&#8203;anirudhaCodes](https://togithub.com/anirudhaCodes) in
[charmbracelet/huh#140
- feat: make `PrevField` and `NextField` public by
[@&#8203;KevM](https://togithub.com/KevM) in
[charmbracelet/huh#175
- feat: accessible mode when `TERM=dumb` by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/huh#188
- feat: `WithOutput` API by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/huh#201
- feat: set note next button label by
[@&#8203;abtmr](https://togithub.com/abtmr) in
[charmbracelet/huh#225

##### Bug Fixes

- fix: overlapping style issue in render function of `field_note` by
[@&#8203;anirudhaCodes](https://togithub.com/anirudhaCodes) in
[charmbracelet/huh#112
- fix: `MultiSelect` limit in Accessible Mode by
[@&#8203;anirudhaCodes](https://togithub.com/anirudhaCodes) in
[charmbracelet/huh#125
- fix: CharLimit of `Text` field in Accessible mode by
[@&#8203;anirudhaCodes](https://togithub.com/anirudhaCodes) in
[charmbracelet/huh#126
- fix: set themes on fields by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/huh#219
- fix: remove temporary file after opening external editor in `Text`
field by [@&#8203;auvred](https://togithub.com/auvred) in
[charmbracelet/huh#154
- fix: spinner bubbles up `tea.Program` errors by
[@&#8203;clowder](https://togithub.com/clowder) in
[charmbracelet/huh#237

#### New Contributors

A special thanks to everyone who made this release of Huh? possible! 🤗

- [@&#8203;theredditbandit](https://togithub.com/theredditbandit) made
their first contribution in
[charmbracelet/huh#102
- [@&#8203;anirudhaCodes](https://togithub.com/anirudhaCodes) made their
first contribution in
[charmbracelet/huh#112
- [@&#8203;rharshit82](https://togithub.com/rharshit82) made their first
contribution in
[charmbracelet/huh#128
- [@&#8203;stefanlogue](https://togithub.com/stefanlogue) made their
first contribution in
[charmbracelet/huh#99
- [@&#8203;auvred](https://togithub.com/auvred) made their first
contribution in
[charmbracelet/huh#154
- [@&#8203;KevM](https://togithub.com/KevM) made their first
contribution in
[charmbracelet/huh#175
- [@&#8203;zimeg](https://togithub.com/zimeg) made their first
contribution in
[charmbracelet/huh#224
- [@&#8203;bradyjoslin](https://togithub.com/bradyjoslin) made their
first contribution in
[charmbracelet/huh#241
- [@&#8203;joshi4](https://togithub.com/joshi4) made their first
contribution in
[charmbracelet/huh#232
- [@&#8203;abtmr](https://togithub.com/abtmr) made their first
contribution in
[charmbracelet/huh#225
- [@&#8203;clowder](https://togithub.com/clowder) made their first
contribution in
[charmbracelet/huh#237

**Full Changelog**:
charmbracelet/huh@v0.3.0...v0.4.0

***

<a href="https://charm.sh/"><img alt="The Charm logo"
src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a>

Thoughts? Questions? We love hearing from you. Feel free to reach out on
[Twitter](https://twitter.com/charmcli), [The
Fediverse](https://mastodon.technology/@&#8203;charm), or
[Slack](https://charm.sh/slack).

###
[`v0.4.1`](https://togithub.com/charmbracelet/huh/compare/v0.4.0...v0.4.1)

[Compare
Source](https://togithub.com/charmbracelet/huh/compare/v0.4.0...v0.4.1)

###
[`v0.4.0`](https://togithub.com/charmbracelet/huh/compare/v0.3.0...v0.4.0)

[Compare
Source](https://togithub.com/charmbracelet/huh/compare/v0.3.0...v0.4.0)

</details>

<details>
<summary>charmbracelet/lipgloss
(github.com/charmbracelet/lipgloss)</summary>

###
[`v0.11.0`](https://togithub.com/charmbracelet/lipgloss/releases/tag/v0.11.0)

[Compare
Source](https://togithub.com/charmbracelet/lipgloss/compare/v0.10.0...v0.11.0)

### Immutable Styles and Raw Speed, Baby

So! The big news in this release is:

-   `Style` methods will now *always* return new styles
-   `Style` and ANSI operations under the hood are faster

There are also a handful of great lil' bug fixes. Read on for more.

#### Immutable Styles

Every `Style` method now returns a completely new style with its own
underlying data structure no matter what. This means working with Styles
is a lot easier. No more need for `Copy()`!

```go
// Before
s := lipgloss.NewStyle().Bold(true)
newStyle := s.Copy()

// After
s := lipgloss.NewStyle().Bold(true)
newStyle := s // this is a true copy
```

Okay, but why are styles easier to work with now? Consider this:

```go
// Before
baseStyle := lipgloss.NewStyle().Background(lipgloss.Color("59"))
styleAtRuntime := baseStyle.Copy().Width(m.Width)

// After
baseStyle := lipgloss.NewStyle().Padding(1, 2)
styleAtRuntime := baseStyle.Width(m.Width)
```

It might seem small, but eliminating the risk of mutations in persistent
styles in an enormous usability improvement.

##### How to upgrade

There's nothing to do, however `Style.Copy()` is now deprecated and only
returns itself, so you can just remove `Style.Copy()` calls. If you need
to *just* copy a style without any changes to it you can simply `b :=
a`.

#### Faster ANSI

Sometimes watch companies brag about their "in-house" watch movement.
Well, now we're bragging about our in-house-amazing
[`x/ansi`](https://togithub.com/charmbracelet/x/tree/main/ansi) library
by our own [@&#8203;aymanbagabas](https://togithub.com/aymanbagabas).
It's a fine-tuned, low-level way to manage ANSI sequencing and, because
we're pretty nerdy, we’re *super* excited about it.

***

#### What's Changed

##### New!

- always return copies of styles by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[charmbracelet/lipgloss#276

##### Changed

- switch to term/ansi for text manipulation by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[charmbracelet/lipgloss#268
- replace stripansi with ansi.Strip in table by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[charmbracelet/lipgloss#271
- test for different GOOS & GOARCH by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[charmbracelet/lipgloss#292

##### Fixed

- fix combining both conditional and unconditional wrapping by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[charmbracelet/lipgloss#275
- fix UnderlineSpaces and StrikethroughSpaces by
[@&#8203;Taz03](https://togithub.com/Taz03) in
[charmbracelet/lipgloss#299
- always render horizontal border edges when enabled by
[@&#8203;UnseenBook](https://togithub.com/UnseenBook) in
[charmbracelet/lipgloss#211
- fix possible nil panic by
[@&#8203;maaslalani](https://togithub.com/maaslalani) in
[charmbracelet/lipgloss#245
- fix transform operating on ANSI sequences by
[@&#8203;meowgorithm](https://togithub.com/meowgorithm) in
[charmbracelet/lipgloss#274
- change propkeys from int to int64 by
[@&#8203;hugoleodev](https://togithub.com/hugoleodev) in
[charmbracelet/lipgloss#291

#### New Contributors

- [@&#8203;benwaffle](https://togithub.com/benwaffle) made their first
contribution in
[charmbracelet/lipgloss#247
- [@&#8203;UnseenBook](https://togithub.com/UnseenBook) made their first
contribution in
[charmbracelet/lipgloss#211
- [@&#8203;hugoleodev](https://togithub.com/hugoleodev) made their first
contribution in
[charmbracelet/lipgloss#291
- [@&#8203;Taz03](https://togithub.com/Taz03) made their first
contribution in
[charmbracelet/lipgloss#299

**Full Changelog**:
charmbracelet/lipgloss@v0.10.0...v0.11.0

***

<a href="https://charm.sh/"><img alt="The Charm logo"
src="https://stuff.charm.sh/charm-badge.jpg" width="400"></a>

Thoughts? Questions? We love hearing from you. Feel free to reach out on
[Twitter](https://twitter.com/charmcli), [The
Fediverse](https://mastodon.technology/@&#8203;charm), or
[Discord](https://charm.sh/discord).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* */8 * * *" (UTC), Automerge - At
any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/jippi/dottie).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zODguMSIsInVwZGF0ZWRJblZlciI6IjM3LjM4OC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian Winther <jippignu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants