widget

package
v0.31.10 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

The widget package contains supported composite and special purpose controls that are not part of the html standard

Index

Constants

View Source
const MegaMenuSelectEvent = "megamenuselect"

Variables

This section is empty.

Functions

func MegaMenuSelect added in v0.7.0

func MegaMenuSelect() *event.Event

Types

type ItemListPanel

type ItemListPanel struct {
	Panel
	FilterPanel *Panel
	ScrollPanel *Panel
	ButtonPanel *Panel

	FilterText *Textbox
	ItemTable  *SelectTable
	NewButton  *Button
	EditButton *Button
}

func NewItemListPanel

func NewItemListPanel(parent page.ControlI, id string) *ItemListPanel

func (*ItemListPanel) DoAction added in v0.23.0

func (f *ItemListPanel) DoAction(ctx context.Context, a action.Params)

func (*ItemListPanel) DrawingAttributes

func (c *ItemListPanel) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*ItemListPanel) Init

func (p *ItemListPanel) Init(self any, parent page.ControlI, id string)

func (*ItemListPanel) Load

func (p *ItemListPanel) Load(ctx context.Context)

type ItemListPanelI

type ItemListPanelI interface {
	PanelI
}

type MegaMenu added in v0.7.0

type MegaMenu struct {
	page.ControlBase
	list.List
	control.DataManager
}

MegaMenu is a control that is the basis for a navigation or action menu that is typically used in a large application. It implements the recommendations at https://www.levelaccess.com/challenges-mega-menus-standard-menus-make-accessible/ to create a natively styled menu, which is keyboard navigable. It tries to avoid the aria-menu item, as that is particularly difficult to implement.

If an item has sub items, it is treated simply as a menu opener, and clicking on that item will not produce an action. If a terminal item has an href, it will be output as a link. Otherwise, it will be output as a button and will fire the "MenuSelectEvent".

There are so many ways to show menus. We attempt to provide some examples, but you might need to add additional styling for your situation.

func GetMegaMenu added in v0.7.0

func GetMegaMenu(c page.ControlI, id string) *MegaMenu

GetMegaMenu is a convenience method to return the control with the given id from the page.

func NewMegaMenu added in v0.7.0

func NewMegaMenu(parent page.ControlI, id string) *MegaMenu

func (*MegaMenu) Deserialize added in v0.7.0

func (l *MegaMenu) Deserialize(dec page.Decoder)

func (*MegaMenu) DrawInnerHtml added in v0.7.0

func (l *MegaMenu) DrawInnerHtml(ctx context.Context, w io.Writer)

func (*MegaMenu) DrawTag added in v0.7.0

func (l *MegaMenu) DrawTag(ctx context.Context, w io.Writer)

func (*MegaMenu) DrawingAttributes added in v0.7.0

func (l *MegaMenu) DrawingAttributes(ctx context.Context) html5tag.Attributes

DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*MegaMenu) GetItemsHtml added in v0.7.0

func (l *MegaMenu) GetItemsHtml(items []*list.Item, level int) string

GetItemsHtml is used by the framework to get the items for the html. It is exported so that it can be overridden by other implementations of an MegaMenu.

func (*MegaMenu) Init added in v0.7.0

func (l *MegaMenu) Init(self any, parent page.ControlI, id string)

func (*MegaMenu) Serialize added in v0.7.0

func (l *MegaMenu) Serialize(e page.Encoder)

func (*MegaMenu) SetAriaLabel added in v0.7.0

func (l *MegaMenu) SetAriaLabel(s string) MegaMenuI

SetAriaLabel sets the aria label that will be used in the tag. e.g. main menu

func (*MegaMenu) SetData added in v0.7.0

func (l *MegaMenu) SetData(data interface{})

SetData replaces the current list with the given data. ValueLabeler, ItemIDer, Labeler or Stringer types are accepted. This function can accept one or more lists of items, or single items. They will all get added to the top level of the list. To add sub items, get a list item and add items to it.

type MegaMenuCreator added in v0.7.0

type MegaMenuCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// AriaLabel is the aria label attribute.
	AriaLabel    string
	OnMenuSelect action.ActionI
	page.ControlOptions
}

func (MegaMenuCreator) Create added in v0.7.0

func (c MegaMenuCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (MegaMenuCreator) Init added in v0.7.0

func (c MegaMenuCreator) Init(ctx context.Context, ctrl MegaMenuI)

type MegaMenuI added in v0.7.0

type MegaMenuI interface {
	page.ControlI
	list.ListI
	control.DataManagerI
	GetItemsHtml(items []*list.Item, level int) string
	SetAriaLabel(l string) MegaMenuI
}

type Recaptcha3 added in v0.13.4

type Recaptcha3 struct {
	page.ControlBase
	SiteKey   string
	SecretKey string
}

func NewRecaptcha3 added in v0.13.4

func NewRecaptcha3(parent page.ControlI, id string) *Recaptcha3

NewRecaptcha3 creates a new recaptcha widget

func (*Recaptcha3) Draw added in v0.13.4

func (r *Recaptcha3) Draw(ctx context.Context, w io.Writer) (err error)

func (*Recaptcha3) Init added in v0.13.4

func (r *Recaptcha3) Init(self any, parent page.ControlI, id string)

Init is called by subclasses of Button to initialize the button control structure.

Jump to

Keyboard shortcuts

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