diff --git a/types/google-apps-script/google-apps-script.card-service.d.ts b/types/google-apps-script/google-apps-script.card-service.d.ts index c92a555a7902be6..b387e51390e15f7 100644 --- a/types/google-apps-script/google-apps-script.card-service.d.ts +++ b/types/google-apps-script/google-apps-script.card-service.d.ts @@ -640,27 +640,84 @@ declare namespace GoogleAppsScript { /** * An input field that allows choosing between a set of predefined options. * - * var checkboxGroup = CardService.newSelectionInput() - * .setType(CardService.SelectionInputType.CHECK_BOX) - * .setTitle("A group of checkboxes. Multiple selections are allowed.") - * .setFieldName("checkbox_field") - * .addItem("checkbox one title", "checkbox_one_value", false) - * .addItem("checkbox two title", "checkbox_two_value", true) - * .addItem("checkbox three title", "checkbox_three_value", false) - * .setOnChangeAction(CardService.newAction() - * .setFunctionName("handleCheckboxChange")); + * const checkboxGroup = + * CardService.newSelectionInput() + * .setType(CardService.SelectionInputType.CHECK_BOX) + * .setTitle('A group of checkboxes. Multiple selections are allowed.') + * .setFieldName('checkbox_field') + * .addItem('checkbox one title', 'checkbox_one_value', false) + * .addItem('checkbox two title', 'checkbox_two_value', true) + * .addItem('checkbox three title', 'checkbox_three_value', true) + * .setOnChangeAction( + * CardService.newAction().setFunctionName('handleCheckboxChange'), + * ); + * + * const radioGroup = + * CardService.newSelectionInput() + * .setType(CardService.SelectionInputType.RADIO_BUTTON) + * .setTitle( + * 'A group of radio buttons. Only a single selection is allowed.') + * .setFieldName('checkbox_field') + * .addItem('radio button one title', 'radio_one_value', true) + * .addItem('radio button two title', 'radio_two_value', false) + * .addItem('radio button three title', 'radio_three_value', false); * - * var radioGroup = CardService.newSelectionInput() - * .setType(CardService.SelectionInputType.RADIO_BUTTON) - * .setTitle("A group of radio buttons. Only a single selection is allowed.") - * .setFieldName("checkbox_field") - * .addItem("radio button one title", "radio_one_value", true) - * .addItem("radio button two title", "radio_two_value", true) - * .addItem("radio button three title", "radio_three_value", false); + * const multiSelect = + * CardService.newSelectionInput() + * .setType(CardService.SelectionInputType.MULTI_SELECT) + * .setFieldName('multiselect') + * .setTitle('A multi select input example.') + * .addMultiSelectItem( + * 'Contact 1', + * 'contact-1', + * false, + * 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png', + * 'Contact one description', + * ) + * .addMultiSelectItem( + * 'Contact 2', + * 'contact-2', + * false, + * 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png', + * 'Contact two description', + * ) + * .addMultiSelectItem( + * 'Contact 3', + * 'contact-3', + * false, + * 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png', + * 'Contact three description', + * ) + * .addMultiSelectItem( + * 'Contact 4', + * 'contact-4', + * false, + * 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png', + * 'Contact four description', + * ) + * .addMultiSelectItem( + * 'Contact 5', + * 'contact-5', + * false, + * 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png', + * 'Contact five description', + * ) + * .setMultiSelectMaxSelectedItems(3) + * .setMultiSelectMinQueryLength(1); */ interface SelectionInput { addItem(text: any, value: any, selected: boolean): SelectionInput; + addMultiSelectItem( + text: string, + value: string, + selected: boolean, + startIconUri: string, + bottomText: string, + ): SelectionInput; + setExternalDataSource(action: Action): SelectionInput; setFieldName(fieldName: string): SelectionInput; + setMultiSelectMaxSelectedItems(maxSelectedItems: Integer): SelectionInput; + setMultiSelectMinQueryLength(queryLength: Integer): SelectionInput; setOnChangeAction(action: Action): SelectionInput; setTitle(title: string): SelectionInput; setType(type: SelectionInputType): SelectionInput; diff --git a/types/google-apps-script/test/google-apps-script-tests.ts b/types/google-apps-script/test/google-apps-script-tests.ts index 2845b61797ae345..ace09b17bd0f958 100644 --- a/types/google-apps-script/test/google-apps-script-tests.ts +++ b/types/google-apps-script/test/google-apps-script-tests.ts @@ -643,6 +643,13 @@ CardService.newOpenLink().setOnClose(CardService.OnClose.RELOAD_ADD_ON); // $Exp // Class CardService.SelectionInput // https://developers.google.com/apps-script/reference/card-service/selection-input CardService.newSelectionInput(); // $ExpectType SelectionInput +CardService.newSelectionInput().addItem("", "", true); // $ExpectType SelectionInput +CardService.newSelectionInput().addMultiSelectItem("", "", false, "", ""); // $ExpectType SelectionInput +CardService.newSelectionInput().setFieldName(""); // $ExpectType SelectionInput +CardService.newSelectionInput().setMultiSelectMaxSelectedItems(5); // $ExpectType SelectionInput +CardService.newSelectionInput().setMultiSelectMinQueryLength(1); // $ExpectType SelectionInput +CardService.newSelectionInput().setTitle(""); // $ExpectType SelectionInput +CardService.newSelectionInput().setType(CardService.SelectionInputType.CHECK_BOX); // $ExpectType SelectionInput // Enum SelectionInputType // https://developers.google.com/apps-script/reference/card-service/selection-input-type