node

package
v0.7.0-alpha.1.pre.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGroup          Group = "default"
	PasswordGroup         Group = "password"
	OpenIDConnectGroup    Group = "oidc"
	ProfileGroup          Group = "profile"
	RecoveryLinkGroup     Group = "link"
	VerificationLinkGroup Group = "link"

	Text   Type = "text"
	Input  Type = "input"
	Image  Type = "img"
	Anchor Type = "a"
)
View Source
const DisableFormField = "disableFormField"

Variables

This section is empty.

Functions

func PasswordLoginOrder

func PasswordLoginOrder(in []string) []string

func SortByGroups

func SortByGroups(orderByGroups []Group) func(*sortOptions)

func SortBySchema

func SortBySchema(schemaRef string) func(*sortOptions)

func SortUpdateOrder

func SortUpdateOrder(f func([]string) []string) func(*sortOptions)

func SortUseOrder

func SortUseOrder(keysInOrder []string) func(*sortOptions)

func WithInputAttributes

func WithInputAttributes(f func(a *InputAttributes)) func(a *InputAttributes)

func WithRequiredInputAttribute

func WithRequiredInputAttribute(a *InputAttributes)

Types

type AnchorAttributes

type AnchorAttributes struct {
	// The link's href (destination) URL.
	//
	// format: uri
	// required: true
	HREF string `json:"href"`

	// The link's title.
	//
	// required: true
	Title *text.Message `json:"title"`
}

AnchorAttributes represents the attributes of an anchor node.

swagger:model uiNodeAnchorAttributes

func (*AnchorAttributes) GetValue

func (a *AnchorAttributes) GetValue() interface{}

func (*AnchorAttributes) ID

func (a *AnchorAttributes) ID() string

func (*AnchorAttributes) Reset

func (a *AnchorAttributes) Reset()

func (*AnchorAttributes) SetValue

func (a *AnchorAttributes) SetValue(value interface{})

type Attributes

type Attributes interface {
	// swagger:ignore
	ID() string

	// swagger:ignore
	Reset()

	// swagger:ignore
	SetValue(value interface{})

	// swagger:ignore
	GetValue() interface{}
}

Attributes represents a list of attributes (e.g. `href="foo"` for links).

swagger:model uiNodeAttributes

type Group

type Group string

swagger:model uiNodeGroup

func (Group) String

func (g Group) String() string

type ImageAttributes

type ImageAttributes struct {
	// The image's source URL.
	//
	// format: uri
	// required: true
	Source string `json:"src"`
}

ImageAttributes represents the attributes of an image node.

swagger:model uiNodeImageAttributes

func (*ImageAttributes) GetValue

func (a *ImageAttributes) GetValue() interface{}

func (*ImageAttributes) ID

func (a *ImageAttributes) ID() string

func (*ImageAttributes) Reset

func (a *ImageAttributes) Reset()

func (*ImageAttributes) SetValue

func (a *ImageAttributes) SetValue(value interface{})

type InputAttributeType

type InputAttributeType string

swagger:model uiNodeInputAttributeType

const (
	InputAttributeTypeText          InputAttributeType = "text"
	InputAttributeTypePassword      InputAttributeType = "password"
	InputAttributeTypeNumber        InputAttributeType = "number"
	InputAttributeTypeCheckbox      InputAttributeType = "checkbox"
	InputAttributeTypeHidden        InputAttributeType = "hidden"
	InputAttributeTypeEmail         InputAttributeType = "email"
	InputAttributeTypeSubmit        InputAttributeType = "submit"
	InputAttributeTypeDateTimeLocal InputAttributeType = "datetime-local"
	InputAttributeTypeDate          InputAttributeType = "date"
	InputAttributeTypeURI           InputAttributeType = "url"
)

type InputAttributes

type InputAttributes struct {
	// The input's element name.
	//
	// required: true
	Name string `json:"name"`

	// The input's element type.
	//
	// required: true
	Type InputAttributeType `json:"type" faker:"-"`

	// The input's value.
	FieldValue interface{} `json:"value,omitempty" faker:"string"`

	// Mark this input field as required.
	Required bool `json:"required,omitempty"`

	// The input's label text.
	Label *text.Message `json:"label,omitempty"`

	// The input's pattern.
	Pattern string `json:"pattern,omitempty"`

	// Sets the input's disabled field to true or false.
	//
	// required: true
	Disabled bool `json:"disabled"`
}

InputAttributes represents the attributes of an input node

swagger:model uiNodeInputAttributes

func (*InputAttributes) GetValue

func (a *InputAttributes) GetValue() interface{}

func (*InputAttributes) ID

func (a *InputAttributes) ID() string

func (*InputAttributes) Reset

func (a *InputAttributes) Reset()

func (*InputAttributes) SetValue

func (a *InputAttributes) SetValue(value interface{})

type InputAttributesModifier

type InputAttributesModifier func(attributes *InputAttributes)

type InputAttributesModifiers

type InputAttributesModifiers []InputAttributesModifier

type Meta

type Meta struct {
	// Label represents the node's label.
	//
	// Keep in mind that these values are autogenerated and can not be changed.
	// If you wish to use other titles or labels implement that directly in
	// your UI.
	Label *text.Message `json:"label,omitempty"`
}

A Node's Meta Information

This might include a label and other information that can optionally be used to render UIs.

type Node

type Node struct {
	// The node's type
	//
	// Can be one of: text, input, img, a
	//
	// required: true
	Type Type `json:"type" faker:"-"`

	// Group specifies which group (e.g. password authenticator) this node belongs to.
	//
	// required: true
	Group Group `json:"group"`

	// The node's attributes.
	//
	// required: true
	// swagger:type uiNodeAttributes
	Attributes Attributes `json:"attributes" faker:"ui_node_attributes"`

	// The node's messages
	//
	// Contains error, validation, or other messages relevant to this node.
	//
	// required: true
	Messages text.Messages `json:"messages"`

	// Meta contains a node meta information
	//
	// This might include a label and other information that can optionally
	// be used to render UIs.
	//
	// required: true
	Meta *Meta `json:"meta"`
}

Node represents a flow's nodes

Nodes are represented as HTML elements or their native UI equivalents. For example, a node can be an `<img>` tag, or an `<input element>` but also `some plain text`.

swagger:model uiNode

func NewCSRFNode

func NewCSRFNode(token string) *Node

func NewInputField

func NewInputField(name string, value interface{}, group Group, inputType InputAttributeType, opts ...InputAttributesModifier) *Node

func NewInputFieldFromJSON

func NewInputFieldFromJSON(name string, value interface{}, group Group, opts ...InputAttributesModifier) *Node

func NewInputFieldFromSchema

func NewInputFieldFromSchema(name string, group Group, p jsonschemax.Path, opts ...InputAttributesModifier) *Node

func (*Node) GetValue

func (n *Node) GetValue() interface{}

func (*Node) ID

func (n *Node) ID() string

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) Reset

func (n *Node) Reset()

func (*Node) UnmarshalJSON

func (n *Node) UnmarshalJSON(data []byte) error

func (*Node) WithMetaLabel

func (n *Node) WithMetaLabel(label *text.Message) *Node

type Nodes

type Nodes []*Node

swagger:model uiNodes

func (*Nodes) Append

func (n *Nodes) Append(node *Node)

Append appends a node.

func (Nodes) Find

func (n Nodes) Find(id string) *Node

func (*Nodes) Remove

func (n *Nodes) Remove(ids ...string)

Remove removes one or more nodes by their IDs.

func (Nodes) Reset

func (n Nodes) Reset(exclude ...string)

func (Nodes) ResetNodes

func (n Nodes) ResetNodes(reset ...string)

func (Nodes) ResetNodesWithPrefix

func (n Nodes) ResetNodesWithPrefix(prefix string)

func (*Nodes) SetValueAttribute

func (n *Nodes) SetValueAttribute(id string, value interface{}) bool

SetValueAttribute sets a node's attribute's value or returns false if no node is found.

func (Nodes) SortBySchema

func (n Nodes) SortBySchema(opts ...SortOption) error

func (*Nodes) Upsert

func (n *Nodes) Upsert(node *Node)

Upsert updates or appends a node.

type SortOption

type SortOption func(*sortOptions)

type TextAttributes

type TextAttributes struct {
	// The text of the text node.
	//
	// required: true
	Text *text.Message `json:"text"`
}

TextAttributes represents the attributes of a text node.

swagger:model uiNodeTextAttributes

func (*TextAttributes) GetValue

func (a *TextAttributes) GetValue() interface{}

func (*TextAttributes) ID

func (a *TextAttributes) ID() string

func (*TextAttributes) Reset

func (a *TextAttributes) Reset()

func (*TextAttributes) SetValue

func (a *TextAttributes) SetValue(value interface{})

type Type

type Type string

swagger:model uiNodeType

Jump to

Keyboard shortcuts

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