popup

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoCurrentPopup indicates that an operation was attempted when no popup was active.
	NoCurrentPopup = fmt.Errorf("no active current popup")
	// CurrentPopupIsntMatchingWithGivenId indicates that the requested popup ID does not match the active popup.
	CurrentPopupIsntMatchingWithGivenId = fmt.Errorf("given id is not matching with the current popup")
)

Functions

This section is empty.

Types

type PopupEvent added in v0.58.2

type PopupEvent struct {
	Type PopupEventType
	Form *apiv1.PopupForm
}

PopupEvent represents a popup lifecycle event delivered to subscribers.

type PopupEventType added in v0.58.2

type PopupEventType int

PopupEventType represents the lifecycle state change of a popup form.

const (
	// PopupEventTypeOpened indicates a new popup has been displayed.
	PopupEventTypeOpened PopupEventType = iota
	// PopupEventTypeDismissed indicates the active popup has been closed or answered.
	PopupEventTypeDismissed
)

type PopupForm

type PopupForm interface {
	// BuildProtoForm constructs the proto message for this popup with the given ID.
	BuildProtoForm(id string) *apiv1.PopupForm
	// Validate handles answer validation for this popup.
	Validate(ctx context.Context, req *apiv1.ValidatePopupAnswerRequest) (*apiv1.ValidatePopupAnswerResponse, error)
	// Answer handles answer submission for this popup. Returns the resolved result string for ShowPopup.
	Answer(ctx context.Context, req *apiv1.SubmitPopupAnswerRequest) (string, error)
}

PopupForm is a polymorphic interface for backend popup implementations.

type PopupManager

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

PopupManager manages questions shown to user from frontend.

var Instance *PopupManager = NewPopupManager()

Instance is the singleton instance of PopupManager.

func NewPopupManager

func NewPopupManager() *PopupManager

NewPopupManager creates an initialized instance of PopupManager.

func (*PopupManager) Answer

Answer processes the finalized answer for the active popup.

func (*PopupManager) DismissActivePopup added in v0.58.2

func (p *PopupManager) DismissActivePopup(id string) error

DismissActivePopup dismisses the active popup from the server side without waiting for user submission.

func (*PopupManager) GetCurrentPopup

func (p *PopupManager) GetCurrentPopup() *apiv1.PopupForm

GetCurrentPopup returns currently active popup proto data needed in frontend side to show the popup.

func (*PopupManager) ShowPopup

func (p *PopupManager) ShowPopup(popup PopupForm) (string, error)

ShowPopup shows the popup UI on frontend side and waits until receiving the input.

func (*PopupManager) Subscribe added in v0.58.2

func (p *PopupManager) Subscribe() (<-chan PopupEvent, func())

Subscribe registers a listener for popup lifecycle events. It returns a receive-only channel and an unsubscribe function to clean up resources.

func (*PopupManager) Validate

Validate receives form input and checks if the request is valid to receive.

type TextPopupForm added in v0.58.2

type TextPopupForm struct {
	Title       string
	Description string
	Placeholder string
	Validator   func(value string) string
}

TextPopupForm represents a standard text input popup.

func (*TextPopupForm) Answer added in v0.58.2

Answer implements PopupForm.

func (*TextPopupForm) BuildProtoForm added in v0.58.2

func (t *TextPopupForm) BuildProtoForm(id string) *apiv1.PopupForm

BuildProtoForm implements PopupForm.

func (*TextPopupForm) Validate added in v0.58.2

Validate implements PopupForm.

Jump to

Keyboard shortcuts

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