5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-09 23:40:27 +00:00
matterbridge/vendor/github.com/slack-go/slack/dialog_text.go

60 lines
1.6 KiB
Go
Raw Permalink Normal View History

package slack
// TextInputSubtype Accepts email, number, tel, or url. In some form factors, optimized input is provided for this subtype.
type TextInputSubtype string
2019-09-07 20:46:58 +00:00
// TextInputOption handle to extra inputs options.
type TextInputOption func(*TextInputElement)
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
2022-11-26 23:42:16 +00:00
// 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
2019-09-07 20:46:58 +00:00
func NewTextInput(name, label, text string, options ...TextInputOption) *TextInputElement {
t := &TextInputElement{
DialogInput: DialogInput{
Type: InputTypeText,
Name: name,
Label: label,
},
Value: text,
}
2019-09-07 20:46:58 +00:00
for _, opt := range options {
opt(t)
}
return t
}
// 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,
}
}