Debian Codegraph @

dialog_text.go

raw symbols SCIP
1 package slack
2
3 // TextInputSubtype Accepts email, number, tel, or url. In some form factors, optimized input is provided for this subtype.
4 type TextInputSubtype string
5
6 // TextInputOption handle to extra inputs options.
7 type TextInputOption func(*TextInputElement)
8
9 const (
10 // InputSubtypeEmail email keyboard
11 InputSubtypeEmail TextInputSubtype = "email"
12 // InputSubtypeNumber numeric keyboard
13 InputSubtypeNumber TextInputSubtype = "number"
14 // InputSubtypeTel Phone keyboard
15 InputSubtypeTel TextInputSubtype = "tel"
16 // InputSubtypeURL Phone keyboard
17 InputSubtypeURL TextInputSubtype = "url"
18 )
19
20 // TextInputElement subtype of DialogInput
21 // https://api.slack.com/dialogs#option_element_attributes#text_element_attributes
22 type TextInputElement struct {
23 DialogInput
24 MaxLength int `json:"max_length,omitempty"`
25 MinLength int `json:"min_length,omitempty"`
26 Hint string `json:"hint,omitempty"`
27 Subtype TextInputSubtype `json:"subtype"`
28 Value string `json:"value"`
29 }
30
31 // NewTextInput constructor for a `text` input
32 func NewTextInput(name, label, text string, options ...TextInputOption) *TextInputElement {
33 t := &TextInputElement{
34 DialogInput: DialogInput{
35 Type: InputTypeText,
36 Name: name,
37 Label: label,
38 },
39 Value: text,
40 }
41
42 for _, opt := range options {
43 opt(t)
44 }
45
46 return t
47 }
48
49 // NewTextAreaInput constructor for a `textarea` input
50 func NewTextAreaInput(name, label, text string) *TextInputElement {
51 return &TextInputElement{
52 DialogInput: DialogInput{
53 Type: InputTypeTextArea,
54 Name: name,
55 Label: label,
56 },
57 Value: text,
58 }
59 }