forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialog_text.go
59 lines (51 loc) · 1.59 KB
/
dialog_text.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package slack
// TextInputSubtype Accepts email, number, tel, or url. In some form factors, optimized input is provided for this subtype.
type TextInputSubtype string
// 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
// 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, options ...TextInputOption) *TextInputElement {
t := &TextInputElement{
DialogInput: DialogInput{
Type: InputTypeText,
Name: name,
Label: label,
},
Value: text,
}
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,
}
}