Codebase list golang-github-nlopes-slack / 25f3707
add optional inputText alexfernandessd authored 4 years ago James committed 4 years ago
2 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
11
22 // TextInputSubtype Accepts email, number, tel, or url. In some form factors, optimized input is provided for this subtype.
33 type TextInputSubtype string
4
5 // TextInputOption hndle to optional inputs
6 type TextInputOption func(*TextInputOption)
47
58 const (
69 // InputSubtypeEmail email keyboard
2528 }
2629
2730 // NewTextInput constructor for a `text` input
28 func NewTextInput(name, label, text string) *TextInputElement {
29 return &TextInputElement{
31 func NewTextInput(name, label, text string, options ...TextInputOption) *TextInputElement {
32 t := &TextInputElement{
3033 DialogInput: DialogInput{
3134 Type: InputTypeText,
3235 Name: name,
3437 },
3538 Value: text,
3639 }
40
41 for _, opt := range options {
42 opt(&t)
43 }
44
45 return t
3746 }
3847
3948 // NewTextAreaInput constructor for a `textarea` input
99 name := "internalName"
1010 label := "Human Readable"
1111 value := "Pre filled text"
12 textInput := NewTextInput(name, label, value)
12 optional := true
13 textInput := NewTextInput(name, label, value, optional)
1314 assert.Equal(t, InputTypeText, textInput.Type)
1415 assert.Equal(t, name, textInput.Name)
1516 assert.Equal(t, label, textInput.Label)
1617 assert.Equal(t, value, textInput.Value)
18 assert.Equal(t, optional, textInput.Optional)
1719 }
1820
1921 func TestNewTextAreaInput(t *testing.T) {