Codebase list golang-github-nlopes-slack / f282e598-9350-4d40-ba4b-90cbf2cd4600/v0.5.0 dialog_text.go
f282e598-9350-4d40-ba4b-90cbf2cd4600/v0.5.0

Tree @f282e598-9350-4d40-ba4b-90cbf2cd4600/v0.5.0 (Download .tar.gz)

dialog_text.go @f282e598-9350-4d40-ba4b-90cbf2cd4600/v0.5.0raw · history · blame

package slack

// TextInputSubtype Accepts email, number, tel, or url. In some form factors, optimized input is provided for this subtype.
type TextInputSubtype string

const (
	// InputSubtypeEmail email keyboard
	InputSubtypeEmail TextInputSubtype = "email"
	// InputSubtypeNumber numeric keyboard
	InputSubtypeNumber TextInputSubtype = "number"
	// InputSubtypeTel Phone keyboard
	InputSubtypeTel TextInputSubtype = "tel"
	// InputSubtypeURL Phone keyboard
	InputSubtypeURL TextInputSubtype = "url"
)

// TextInputElement subtype of DialogInput
//	https://api.slack.com/dialogs#option_element_attributes#text_element_attributes
type TextInputElement struct {
	DialogInput
	MaxLength int              `json:"max_length,omitempty"`
	MinLength int              `json:"min_length,omitempty"`
	Hint      string           `json:"hint,omitempty"`
	Subtype   TextInputSubtype `json:"subtype"`
	Value     string           `json:"value"`
}

// NewTextInput constructor for a `text` input
func NewTextInput(name, label, text string) *TextInputElement {
	return &TextInputElement{
		DialogInput: DialogInput{
			Type:  InputTypeText,
			Name:  name,
			Label: label,
		},
		Value: text,
	}
}

// NewTextAreaInput constructor for a `textarea` input
func NewTextAreaInput(name, label, text string) *TextInputElement {
	return &TextInputElement{
		DialogInput: DialogInput{
			Type:  InputTypeTextArea,
			Name:  name,
			Label: label,
		},
		Value: text,
	}
}