Documentation
¶
Overview ¶
Package render provides UI component builders for dynamic rendering
Package render provides confirmation dialog UI component ¶
Package render provides form input UI component ¶
Package render provides list selection UI component ¶
Package render provides table display UI component ¶
Package render provides interactive UI tools for the assistant.
Index ¶
- func QuickConfirm(message string, defaultYes bool, output io.Writer) (bool, error)
- type Builder
- type ConfirmBuilder
- type ConfirmData
- type ConfirmModel
- type ConfirmStyles
- type FormBuilder
- func (b *FormBuilder) AddNumberField(id, label string, min, max float64, required bool) *FormBuilder
- func (b *FormBuilder) AddPasswordField(id, label, placeholder string, required bool) *FormBuilder
- func (b *FormBuilder) AddSelectField(id, label string, options []string, defaultValue string, required bool) *FormBuilder
- func (b *FormBuilder) AddTextField(id, label, placeholder string, required bool) *FormBuilder
- func (b *FormBuilder) Build() UIRequest
- func (b *FormBuilder) WithCancelLabel(label string) *FormBuilder
- func (b *FormBuilder) WithSubmitLabel(label string) *FormBuilder
- func (b *FormBuilder) WithTitle(title string) *FormBuilder
- type FormData
- type FormField
- type FormModel
- type FormStyles
- type ListBuilder
- type ListData
- type ListItem
- type ListModel
- type ListStyles
- type TableBuilder
- func (b *TableBuilder) AddColumn(id, title string, width int, align string) *TableBuilder
- func (b *TableBuilder) AddRow(id string, values map[string]string) *TableBuilder
- func (b *TableBuilder) Build() UIRequest
- func (b *TableBuilder) ShowHeaders(show bool) *TableBuilder
- func (b *TableBuilder) WithTitle(title string) *TableBuilder
- type TableColumn
- type TableData
- type TableModel
- type TableRow
- type TableStyles
- type UIOptions
- type UIRequest
- type UIResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides methods to construct UI components programmatically.
func (*Builder) WithDescription ¶
WithDescription sets the description.
func (*Builder) WithOptions ¶
WithOptions sets UI options.
type ConfirmBuilder ¶
type ConfirmBuilder struct {
*Builder
// contains filtered or unexported fields
}
ConfirmBuilder provides fluent API for building confirmations.
func NewConfirmBuilder ¶
func NewConfirmBuilder(message string) *ConfirmBuilder
NewConfirmBuilder creates a new confirmation builder.
func (*ConfirmBuilder) Build ¶
func (b *ConfirmBuilder) Build() UIRequest
Build finalizes the confirmation request.
func (*ConfirmBuilder) DefaultNo ¶
func (b *ConfirmBuilder) DefaultNo() *ConfirmBuilder
DefaultNo sets the default selection to No.
func (*ConfirmBuilder) DefaultYes ¶
func (b *ConfirmBuilder) DefaultYes() *ConfirmBuilder
DefaultYes sets the default selection to Yes.
func (*ConfirmBuilder) WithTitle ¶
func (b *ConfirmBuilder) WithTitle(title string) *ConfirmBuilder
WithTitle sets the title for confirmation.
type ConfirmData ¶
ConfirmData contains data for confirmation dialog.
type ConfirmModel ¶
type ConfirmModel struct {
// contains filtered or unexported fields
}
ConfirmModel is a Bubble Tea model for confirmation dialogs.
func NewConfirmModel ¶
func NewConfirmModel(req UIRequest) (*ConfirmModel, error)
NewConfirmModel creates a new confirmation dialog model.
func (*ConfirmModel) Result ¶
func (m *ConfirmModel) Result() UIResponse
Result returns the confirmation result.
func (*ConfirmModel) View ¶
func (m *ConfirmModel) View() string
View renders the confirmation dialog.
type ConfirmStyles ¶
type ConfirmStyles struct {
Title lipgloss.Style
Description lipgloss.Style
Message lipgloss.Style
Button lipgloss.Style
ActiveButton lipgloss.Style
Help lipgloss.Style
}
ConfirmStyles contains styles for confirmation dialog.
func DefaultConfirmStyles ¶
func DefaultConfirmStyles() *ConfirmStyles
DefaultConfirmStyles returns default styles for confirmation.
type FormBuilder ¶
type FormBuilder struct {
*Builder
// contains filtered or unexported fields
}
FormBuilder provides fluent API for building forms.
func (*FormBuilder) AddNumberField ¶
func (b *FormBuilder) AddNumberField(id, label string, min, max float64, required bool) *FormBuilder
AddNumberField adds a number field.
func (*FormBuilder) AddPasswordField ¶
func (b *FormBuilder) AddPasswordField(id, label, placeholder string, required bool) *FormBuilder
AddPasswordField adds a password field.
func (*FormBuilder) AddSelectField ¶
func (b *FormBuilder) AddSelectField(id, label string, options []string, defaultValue string, required bool) *FormBuilder
AddSelectField adds a select field.
func (*FormBuilder) AddTextField ¶
func (b *FormBuilder) AddTextField(id, label, placeholder string, required bool) *FormBuilder
AddTextField adds a text field.
func (*FormBuilder) Build ¶
func (b *FormBuilder) Build() UIRequest
Build finalizes the form request.
func (*FormBuilder) WithCancelLabel ¶
func (b *FormBuilder) WithCancelLabel(label string) *FormBuilder
WithCancelLabel sets the cancel button label.
func (*FormBuilder) WithSubmitLabel ¶
func (b *FormBuilder) WithSubmitLabel(label string) *FormBuilder
WithSubmitLabel sets the submit button label.
func (*FormBuilder) WithTitle ¶
func (b *FormBuilder) WithTitle(title string) *FormBuilder
WithTitle sets the title for form.
type FormData ¶
type FormData struct {
Fields []FormField `json:"fields"`
}
FormData contains data for form UI.
type FormField ¶
type FormField struct {
ID string `json:"id"`
Label string `json:"label"`
Type string `json:"type"` // "text", "password", "number", "select", "checkbox"
Required bool `json:"required,omitempty"`
Default interface{} `json:"default,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Options []string `json:"options,omitempty"` // For select type
Min float64 `json:"min,omitempty"` // For number type
Max float64 `json:"max,omitempty"` // For number type
Pattern string `json:"pattern,omitempty"` // Regex validation
}
FormField represents a field in a form.
type FormModel ¶
type FormModel struct {
// contains filtered or unexported fields
}
FormModel is a Bubble Tea model for form input.
func NewFormModel ¶
NewFormModel creates a new form input model.
type FormStyles ¶
type FormStyles struct {
Title lipgloss.Style
Description lipgloss.Style
Label lipgloss.Style
Input lipgloss.Style
Error lipgloss.Style
Help lipgloss.Style
Button lipgloss.Style
ActiveButton lipgloss.Style
}
FormStyles contains styles for form rendering.
func DefaultFormStyles ¶
func DefaultFormStyles() *FormStyles
DefaultFormStyles returns default styles for form.
type ListBuilder ¶
type ListBuilder struct {
*Builder
// contains filtered or unexported fields
}
ListBuilder provides fluent API for building list selections.
func (*ListBuilder) AddItem ¶
func (b *ListBuilder) AddItem(id, title, description string, value interface{}) *ListBuilder
AddItem adds an item to the list.
func (*ListBuilder) Build ¶
func (b *ListBuilder) Build() UIRequest
Build finalizes the list request.
func (*ListBuilder) MultiSelect ¶
func (b *ListBuilder) MultiSelect(enabled bool) *ListBuilder
MultiSelect enables multi-selection mode.
func (*ListBuilder) WithTitle ¶
func (b *ListBuilder) WithTitle(title string) *ListBuilder
WithTitle sets the title for list.
type ListItem ¶
type ListItem struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
Selected bool `json:"selected,omitempty"`
}
ListItem represents an item in a list selection.
type ListModel ¶
type ListModel struct {
// contains filtered or unexported fields
}
ListModel is a Bubble Tea model for list selection.
func NewListModel ¶
NewListModel creates a new list selection model.
func (*ListModel) Result ¶
func (m *ListModel) Result() UIResponse
Result returns the selection result.
type ListStyles ¶
type ListStyles struct {
Title lipgloss.Style
Description lipgloss.Style
Item lipgloss.Style
Selected lipgloss.Style
Cursor lipgloss.Style
Help lipgloss.Style
}
ListStyles contains styles for list rendering.
func DefaultListStyles ¶
func DefaultListStyles() *ListStyles
DefaultListStyles returns default styles for list.
type TableBuilder ¶
type TableBuilder struct {
*Builder
// contains filtered or unexported fields
}
TableBuilder provides fluent API for building tables.
func NewTableBuilder ¶
func NewTableBuilder() *TableBuilder
NewTableBuilder creates a new table builder.
func (*TableBuilder) AddColumn ¶
func (b *TableBuilder) AddColumn(id, title string, width int, align string) *TableBuilder
AddColumn adds a column definition.
func (*TableBuilder) AddRow ¶
func (b *TableBuilder) AddRow(id string, values map[string]string) *TableBuilder
AddRow adds a row to the table.
func (*TableBuilder) Build ¶
func (b *TableBuilder) Build() UIRequest
Build finalizes the table request.
func (*TableBuilder) ShowHeaders ¶
func (b *TableBuilder) ShowHeaders(show bool) *TableBuilder
ShowHeaders enables header display.
func (*TableBuilder) WithTitle ¶
func (b *TableBuilder) WithTitle(title string) *TableBuilder
WithTitle sets the title for table.
type TableColumn ¶
type TableColumn struct {
ID string `json:"id"`
Title string `json:"title"`
Width int `json:"width,omitempty"`
Align string `json:"align,omitempty"` // "left", "center", "right"
}
TableColumn represents a column in a table.
type TableData ¶
type TableData struct {
Columns []TableColumn `json:"columns"`
Rows []TableRow `json:"rows"`
}
TableData contains data for table display.
type TableModel ¶
type TableModel struct {
// contains filtered or unexported fields
}
TableModel is a Bubble Tea model for table display.
func NewTableModel ¶
func NewTableModel(req UIRequest) (*TableModel, error)
NewTableModel creates a new table display model.
func (*TableModel) Result ¶
func (m *TableModel) Result() UIResponse
Result returns the table interaction result.
type TableStyles ¶
type TableStyles struct {
Title lipgloss.Style
Description lipgloss.Style
Header lipgloss.Style
Row lipgloss.Style
Selected lipgloss.Style
Cursor lipgloss.Style
Border lipgloss.Style
Help lipgloss.Style
}
TableStyles contains styles for table rendering.
func DefaultTableStyles ¶
func DefaultTableStyles() *TableStyles
DefaultTableStyles returns default styles for table.
type UIOptions ¶
type UIOptions struct {
// Common options
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
ShowHelp bool `json:"show_help,omitempty"`
AllowCancel bool `json:"allow_cancel,omitempty"`
// List options
MultiSelect bool `json:"multi_select,omitempty"`
ShowIndices bool `json:"show_indices,omitempty"`
// Form options
SubmitLabel string `json:"submit_label,omitempty"`
CancelLabel string `json:"cancel_label,omitempty"`
// Table options
ShowHeaders bool `json:"show_headers,omitempty"`
Sortable bool `json:"sortable,omitempty"`
Filterable bool `json:"filterable,omitempty"`
}
UIOptions provides display options for UI components.
type UIRequest ¶
type UIRequest struct {
// Common fields
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type"` // "list", "form", "table", "confirm"
Data json.RawMessage `json:"data"`
Options UIOptions `json:"options,omitempty"`
}
UIRequest represents a request to display a UI component.
type UIResponse ¶
type UIResponse struct {
Type string `json:"type"`
Selected interface{} `json:"selected,omitempty"`
Input interface{} `json:"input,omitempty"`
Canceled bool `json:"canceled"`
Duration time.Duration `json:"duration"`
Data json.RawMessage `json:"data,omitempty"`
}
UIResponse represents the result of a UI interaction.
func RunConfirm ¶
func RunConfirm(req UIRequest, output io.Writer) (UIResponse, error)
RunConfirm runs a confirmation dialog and returns the result.
func RunForm ¶
func RunForm(req UIRequest, output io.Writer) (UIResponse, error)
RunForm runs a form UI and returns the result.