Skip to content

Commit 0c7ee6b

Browse files
committed
input moved back into options provider (behaviour too specific to generalise into a component)
1 parent bdbccbe commit 0c7ee6b

5 files changed

Lines changed: 19 additions & 32 deletions

File tree

internal/tui/components/Input/config.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

internal/tui/components/OptionsProvider/component.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
tea "github.com/charmbracelet/bubbletea"
99
"github.com/charmbracelet/lipgloss"
1010
"github.com/maniac-en/req/internal/log"
11-
input "github.com/maniac-en/req/internal/tui/components/Input"
1211
"github.com/maniac-en/req/internal/tui/keybinds"
1312
"github.com/maniac-en/req/internal/tui/messages"
1413
)
@@ -22,7 +21,7 @@ const (
2221

2322
type OptionsProvider[T, U any] struct {
2423
list list.Model
25-
input input.OptionsInput
24+
input OptionsInput
2625
onSelectAction tea.Msg
2726
keys *keybinds.ListKeyMap
2827
width int
@@ -191,12 +190,12 @@ func initList[T, U any](config *ListConfig[T, U]) list.Model {
191190

192191
func NewOptionsProvider[T, U any](config *ListConfig[T, U]) OptionsProvider[T, U] {
193192

194-
inputConfig := input.InputConfig{
193+
inputConfig := InputConfig{
195194
CharLimit: 100,
196195
Placeholder: "Add A New Collection...",
197196
Width: 22,
198197
Prompt: "",
199-
KeyMap: input.InputKeyMaps{
198+
KeyMap: InputKeyMaps{
200199
Accept: config.AdditionalKeymaps.Accept,
201200
Back: config.AdditionalKeymaps.Back,
202201
},
@@ -205,7 +204,7 @@ func NewOptionsProvider[T, U any](config *ListConfig[T, U]) OptionsProvider[T, U
205204
return OptionsProvider[T, U]{
206205
list: initList(config),
207206
focused: listComponent,
208-
input: input.NewOptionsInput(&inputConfig),
207+
input: NewOptionsInput(&inputConfig),
209208
getItems: config.GetItemsFunc,
210209
itemMapper: config.ItemMapper,
211210
keys: config.AdditionalKeymaps,

internal/tui/components/OptionsProvider/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package optionsProvider
22

33
import (
44
"context"
5+
"github.com/charmbracelet/bubbles/key"
56

67
"github.com/charmbracelet/bubbles/list"
78
tea "github.com/charmbracelet/bubbletea"
@@ -28,3 +29,16 @@ type ListConfig[T, U any] struct {
2829
GetItemsFunc func(context.Context) ([]T, error)
2930
// Style lipgloss.Style
3031
}
32+
33+
type InputConfig struct {
34+
Prompt string
35+
Placeholder string
36+
CharLimit int
37+
Width int
38+
KeyMap InputKeyMaps
39+
}
40+
41+
type InputKeyMaps struct {
42+
Accept key.Binding
43+
Back key.Binding
44+
}

internal/tui/components/Input/input.go renamed to internal/tui/components/OptionsProvider/input.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package input
1+
package optionsProvider
22

33
import (
44
"github.com/charmbracelet/bubbles/key"

internal/tui/keybinds/keys.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ type Keymaps struct {
2222
Quit key.Binding
2323
}
2424

25-
func (k Keymaps) ShortHelp() []key.Binding {
26-
return []key.Binding{
27-
k.Quit,
28-
}
29-
}
30-
31-
func (k Keymaps) FullHelp() [][]key.Binding {
32-
return [][]key.Binding{}
33-
}
34-
3525
var Keys = Keymaps{
3626
Back: key.NewBinding(
3727
key.WithKeys("esc"),

0 commit comments

Comments
 (0)