Skip to content

Commit d3c022e

Browse files
🤖 Merge PR DefinitelyTyped#73693 Google-Apps-Script: Added MultiSelect to SelectionInput by @YamanquiChacala
Co-authored-by: Yamanqui García Rosales <yamanqui@gmail.com>
1 parent b668938 commit d3c022e

File tree

2 files changed

+74
-16
lines changed

2 files changed

+74
-16
lines changed

‎types/google-apps-script/google-apps-script.card-service.d.ts‎

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -640,27 +640,78 @@ declare namespace GoogleAppsScript {
640640
/**
641641
* An input field that allows choosing between a set of predefined options.
642642
*
643-
* var checkboxGroup = CardService.newSelectionInput()
644-
* .setType(CardService.SelectionInputType.CHECK_BOX)
645-
* .setTitle("A group of checkboxes. Multiple selections are allowed.")
646-
* .setFieldName("checkbox_field")
647-
* .addItem("checkbox one title", "checkbox_one_value", false)
648-
* .addItem("checkbox two title", "checkbox_two_value", true)
649-
* .addItem("checkbox three title", "checkbox_three_value", false)
650-
* .setOnChangeAction(CardService.newAction()
651-
* .setFunctionName("handleCheckboxChange"));
643+
* const checkboxGroup =
644+
* CardService.newSelectionInput()
645+
* .setType(CardService.SelectionInputType.CHECK_BOX)
646+
* .setTitle('A group of checkboxes. Multiple selections are allowed.')
647+
* .setFieldName('checkbox_field')
648+
* .addItem('checkbox one title', 'checkbox_one_value', false)
649+
* .addItem('checkbox two title', 'checkbox_two_value', true)
650+
* .addItem('checkbox three title', 'checkbox_three_value', true)
651+
* .setOnChangeAction(
652+
* CardService.newAction().setFunctionName('handleCheckboxChange'),
653+
* );
652654
*
653-
* var radioGroup = CardService.newSelectionInput()
654-
* .setType(CardService.SelectionInputType.RADIO_BUTTON)
655-
* .setTitle("A group of radio buttons. Only a single selection is allowed.")
656-
* .setFieldName("checkbox_field")
657-
* .addItem("radio button one title", "radio_one_value", true)
658-
* .addItem("radio button two title", "radio_two_value", true)
659-
* .addItem("radio button three title", "radio_three_value", false);
655+
* const radioGroup =
656+
* CardService.newSelectionInput()
657+
* .setType(CardService.SelectionInputType.RADIO_BUTTON)
658+
* .setTitle(
659+
* 'A group of radio buttons. Only a single selection is allowed.')
660+
* .setFieldName('checkbox_field')
661+
* .addItem('radio button one title', 'radio_one_value', true)
662+
* .addItem('radio button two title', 'radio_two_value', false)
663+
* .addItem('radio button three title', 'radio_three_value', false);
664+
*
665+
* const multiSelect =
666+
* CardService.newSelectionInput()
667+
* .setType(CardService.SelectionInputType.MULTI_SELECT)
668+
* .setFieldName('multiselect')
669+
* .setTitle('A multi select input example.')
670+
* .addMultiSelectItem(
671+
* 'Contact 1',
672+
* 'contact-1',
673+
* false,
674+
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
675+
* 'Contact one description',
676+
* )
677+
* .addMultiSelectItem(
678+
* 'Contact 2',
679+
* 'contact-2',
680+
* false,
681+
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
682+
* 'Contact two description',
683+
* )
684+
* .addMultiSelectItem(
685+
* 'Contact 3',
686+
* 'contact-3',
687+
* false,
688+
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
689+
* 'Contact three description',
690+
* )
691+
* .addMultiSelectItem(
692+
* 'Contact 4',
693+
* 'contact-4',
694+
* false,
695+
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
696+
* 'Contact four description',
697+
* )
698+
* .addMultiSelectItem(
699+
* 'Contact 5',
700+
* 'contact-5',
701+
* false,
702+
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
703+
* 'Contact five description',
704+
* )
705+
* .setMultiSelectMaxSelectedItems(3)
706+
* .setMultiSelectMinQueryLength(1);
660707
*/
661708
interface SelectionInput {
662709
addItem(text: any, value: any, selected: boolean): SelectionInput;
710+
addMultiSelectItem(text: string, value: string, selected: boolean, startIconUri: string, bottomText: string): SelectionInput;
711+
setExternalDataSource(action: Action): SelectionInput;
663712
setFieldName(fieldName: string): SelectionInput;
713+
setMultiSelectMaxSelectedItems(maxSelectedItems: Integer): SelectionInput;
714+
setMultiSelectMinQueryLength(queryLength: Integer): SelectionInput
664715
setOnChangeAction(action: Action): SelectionInput;
665716
setTitle(title: string): SelectionInput;
666717
setType(type: SelectionInputType): SelectionInput;

‎types/google-apps-script/test/google-apps-script-tests.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,13 @@ CardService.newOpenLink().setOnClose(CardService.OnClose.RELOAD_ADD_ON); // $Exp
643643
// Class CardService.SelectionInput
644644
// https://developers.google.com/apps-script/reference/card-service/selection-input
645645
CardService.newSelectionInput(); // $ExpectType SelectionInput
646+
CardService.newSelectionInput().addItem('', '', true); // $ExpectType SelectionInput
647+
CardService.newSelectionInput().addMultiSelectItem('', '', false, '', ''); // $ExpectType SelectionInput
648+
CardService.newSelectionInput().setFieldName(''); // $ExpectType SelectionInput
649+
CardService.newSelectionInput().setMultiSelectMaxSelectedItems(5); // $ExpectType SelectionInput
650+
CardService.newSelectionInput().setMultiSelectMinQueryLength(1); // $ExpectType SelectionInput
651+
CardService.newSelectionInput().setTitle(''); // $ExpectType SelectionInput
652+
CardService.newSelectionInput().setType(CardService.SelectionInputType.CHECK_BOX); // $ExpectType SelectionInput
646653

647654
// Enum SelectionInputType
648655
// https://developers.google.com/apps-script/reference/card-service/selection-input-type

0 commit comments

Comments
 (0)