ui

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TitleStyle for headers and titles.
	TitleStyle lipgloss.Style

	// SelectedStyle for currently selected items.
	SelectedStyle lipgloss.Style

	// NormalStyle for regular text.
	NormalStyle lipgloss.Style

	// DimStyle for secondary/muted text.
	DimStyle lipgloss.Style

	// ErrorStyle for error messages.
	ErrorStyle lipgloss.Style

	// SuccessStyle for success messages.
	SuccessStyle lipgloss.Style

	// SpinnerStyle for loading spinners.
	SpinnerStyle lipgloss.Style

	// HelpStyle for help text.
	HelpStyle lipgloss.Style

	// BorderStyle for bordered containers.
	BorderStyle lipgloss.Style

	// HighlightStyle for emphasized content.
	HighlightStyle lipgloss.Style

	// InputStyle for text inputs.
	InputStyle lipgloss.Style

	// PromptStyle for prompts and labels.
	PromptStyle lipgloss.Style
)
View Source
var ErrCanceled = errors.New("operation canceled")

ErrCanceled indicates user canceled the operation.

Functions

func ConfirmPrompt

func ConfirmPrompt(message string) (bool, error)

ConfirmPrompt displays a yes/no confirmation prompt.

func NumberPrompt

func NumberPrompt(message string, defaultVal float64) (float64, error)

NumberPrompt displays a numeric input prompt.

func RunProgram

func RunProgram(model tea.Model) error

RunProgram executes a bubbletea program and returns any error.

func TextPrompt

func TextPrompt(message, placeholder string) (string, error)

TextPrompt displays a text input prompt.

func WithSpinner

func WithSpinner[T any](message string, fn func() (T, error)) (T, error)

WithSpinner executes a function while displaying a spinner.

Types

type ClientItem

type ClientItem struct {
	ClientID   int64
	ClientName string
}

ClientItem implements PickerItem for Harvest clients.

func (ClientItem) Description

func (c ClientItem) Description() string

func (ClientItem) ID

func (c ClientItem) ID() int64

func (ClientItem) Title

func (c ClientItem) Title() string

type DashboardModel

type DashboardModel struct {
	Running    *api.TimeEntry
	TodayHours float64
	WeekHours  float64
	WeekTarget float64
	DailyHours map[string]float64 // key: "Mon", "Tue", etc.
	WeekStart  time.Time
}

DashboardModel holds dashboard state and data.

func NewDashboard

func NewDashboard(entries []api.TimeEntry, running *api.TimeEntry, weekStart time.Time, weekTarget float64) *DashboardModel

NewDashboard creates a dashboard model from entries.

func (*DashboardModel) View

func (m *DashboardModel) View() string

View renders the dashboard as a string.

type DateStep

type DateStep struct {
	Message string
	Default time.Time
}

DateStep prompts for a date.

func (*DateStep) Name

func (s *DateStep) Name() string

func (*DateStep) Run

func (s *DateStep) Run(_ map[string]any) (map[string]any, error)

type HoursStep

type HoursStep struct {
	Message string
	Default float64
}

HoursStep prompts for hours.

func (*HoursStep) Name

func (s *HoursStep) Name() string

func (*HoursStep) Run

func (s *HoursStep) Run(_ map[string]any) (map[string]any, error)

type NotesStep

type NotesStep struct {
	Message  string
	Required bool
}

NotesStep prompts for notes.

func (*NotesStep) Name

func (s *NotesStep) Name() string

func (*NotesStep) Run

func (s *NotesStep) Run(_ map[string]any) (map[string]any, error)

type Picker

type Picker struct {
	// contains filtered or unexported fields
}

Picker is a searchable list picker for selecting items.

func NewPicker

func NewPicker(title string, items []PickerItem) *Picker

NewPicker creates a new picker with the given title and items.

func (*Picker) Canceled

func (p *Picker) Canceled() bool

Canceled returns true if the picker was canceled.

func (*Picker) Init

func (p *Picker) Init() tea.Cmd

Init implements tea.Model.

func (*Picker) Run

func (p *Picker) Run() (PickerItem, error)

Run executes the picker and returns the selected item.

func (*Picker) Selected

func (p *Picker) Selected() PickerItem

Selected returns the selected item (nil if none).

func (*Picker) Update

func (p *Picker) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (*Picker) View

func (p *Picker) View() string

View implements tea.Model.

type PickerItem

type PickerItem interface {
	ID() int64
	Title() string
	Description() string
}

PickerItem interface for items displayed in the picker.

type ProjectItem

type ProjectItem struct {
	ProjectID   int64
	ProjectName string
	ClientName  string
	Code        string
}

ProjectItem implements PickerItem for Harvest projects.

func PickProject

func PickProject(title string, projects []ProjectItem) (*ProjectItem, error)

PickProject shows a project picker and returns the selected project.

func (ProjectItem) Description

func (p ProjectItem) Description() string

func (ProjectItem) ID

func (p ProjectItem) ID() int64

func (ProjectItem) Title

func (p ProjectItem) Title() string

type ProjectStep

type ProjectStep struct {
	Projects []ProjectItem
}

ProjectStep prompts for project selection.

func (*ProjectStep) Name

func (s *ProjectStep) Name() string

func (*ProjectStep) Run

func (s *ProjectStep) Run(data map[string]any) (map[string]any, error)

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner displays a loading indicator with a message.

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with the given message.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins displaying the spinner.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop terminates the spinner display.

type TaskItem

type TaskItem struct {
	TaskID   int64
	TaskName string
	Billable bool
}

TaskItem implements PickerItem for Harvest tasks.

func PickTask

func PickTask(title string, tasks []TaskItem) (*TaskItem, error)

PickTask shows a task picker and returns the selected task.

func (TaskItem) Description

func (t TaskItem) Description() string

func (TaskItem) ID

func (t TaskItem) ID() int64

func (TaskItem) Title

func (t TaskItem) Title() string

type TaskStep

type TaskStep struct {
	TasksFn func(projectID int64) ([]TaskItem, error)
}

TaskStep prompts for task selection.

func (*TaskStep) Name

func (s *TaskStep) Name() string

func (*TaskStep) Run

func (s *TaskStep) Run(data map[string]any) (map[string]any, error)

type TimeEntryData

type TimeEntryData struct {
	ProjectID   int64
	ProjectName string
	TaskID      int64
	TaskName    string
	SpentDate   string
	Hours       float64
	Notes       string
}

TimeEntryFromWizard extracts time entry data from wizard results.

func ParseTimeEntryData

func ParseTimeEntryData(data map[string]any) (*TimeEntryData, error)

ParseTimeEntryData extracts structured data from wizard results.

type UserItem

type UserItem struct {
	UserID    int64
	FirstName string
	LastName  string
	Email     string
}

UserItem implements PickerItem for Harvest users.

func (UserItem) Description

func (u UserItem) Description() string

func (UserItem) ID

func (u UserItem) ID() int64

func (UserItem) Title

func (u UserItem) Title() string

type Wizard

type Wizard struct {
	// contains filtered or unexported fields
}

Wizard is a multi-step form for collecting data.

func NewTimeEntryWizard

func NewTimeEntryWizard(projects []ProjectItem, tasksFn func(int64) ([]TaskItem, error)) *Wizard

NewTimeEntryWizard creates a wizard for creating time entries.

func NewWizard

func NewWizard(steps ...WizardStep) *Wizard

NewWizard creates a new wizard with the given steps.

func (*Wizard) Canceled

func (w *Wizard) Canceled() bool

Canceled returns true if the wizard was canceled.

func (*Wizard) Data

func (w *Wizard) Data() map[string]any

Data returns the collected data.

func (*Wizard) Run

func (w *Wizard) Run() (map[string]any, error)

Run executes all wizard steps sequentially.

type WizardStep

type WizardStep interface {
	Name() string
	Run(data map[string]any) (map[string]any, error)
}

WizardStep represents a step in a multi-step wizard.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL