@@ -15,6 +15,18 @@ import {
1515} from "@rocket.chat/ui-kit" ;
1616import { APP_ID } from "../constants" ;
1717
18+ /**
19+ * Creates an input block with a label and a plain text input element.
20+ *
21+ * @param labelText - The text to be displayed as the label for the input block.
22+ * @param placeholderText - The text to be displayed as the placeholder for the plain text input element.
23+ * @param blockId - The unique identifier for the input block.
24+ * @param actionId - The unique identifier for the action associated with the input block.
25+ * @param initialValue - The initial value to be displayed in the plain text input element (optional).
26+ * @param multiline - A boolean value indicating whether the plain text input element should support multiple lines (optional).
27+ *
28+ * @returns A promise that resolves to an InputBlock object representing the created input block.
29+ */
1830export async function getInputBox (
1931 labelText : string ,
2032 placeholderText : string ,
@@ -45,6 +57,16 @@ export async function getInputBox(
4557 return block ;
4658}
4759
60+ /**
61+ * Creates an input block with a datepicker element.
62+ *
63+ * @param labelText - The label text for the input block.
64+ * @param placeholderText - The placeholder text for the datepicker element.
65+ * @param blockId - The ID of the block.
66+ * @param actionId - The ID of the action.
67+ * @param initialDate - The initial date for the datepicker element (optional).
68+ * @returns A promise that resolves to an InputBlock object.
69+ */
4870export async function getInputBoxDate (
4971 labelText : string ,
5072 placeholderText : string ,
@@ -73,6 +95,16 @@ export async function getInputBoxDate(
7395 return block ;
7496}
7597
98+ /**
99+ * Creates a button element with the specified properties.
100+ * @param labelText - The text to be displayed on the button.
101+ * @param blockId - The ID of the block containing the button.
102+ * @param actionId - The ID of the action associated with the button.
103+ * @param value - The optional value associated with the button.
104+ * @param style - The optional style of the button. Can be either ButtonStyle.PRIMARY or ButtonStyle.DANGER.
105+ * @param url - The optional URL to be opened when the button is clicked.
106+ * @returns A promise that resolves to a ButtonElement.
107+ */
76108export async function getButton (
77109 labelText : string ,
78110 blockId : string ,
@@ -97,6 +129,13 @@ export async function getButton(
97129 return button ;
98130}
99131
132+ /**
133+ * Creates a section block for a Slack message.
134+ *
135+ * @param labelText - The label text to be displayed in the section block.
136+ * @param accessory - An optional accessory to be included in the section block.
137+ * @returns A promise that resolves to a SectionBlock object.
138+ */
100139export async function getSectionBlock (
101140 labelText : string ,
102141 accessory ?: any
@@ -112,13 +151,23 @@ export async function getSectionBlock(
112151 return block ;
113152}
114153
154+ /**
155+ * Retrieves a DividerBlock.
156+ *
157+ * @returns A Promise that resolves to a DividerBlock object.
158+ */
115159export async function getDividerBlock ( ) : Promise < DividerBlock > {
116160 const block : DividerBlock = {
117161 type : "divider" ,
118162 } ;
119163 return block ;
120164}
121165
166+ /**
167+ * Creates a context block with the specified element text.
168+ * @param elementText - The text to be displayed in the context block.
169+ * @returns A Promise that resolves to a ContextBlock object.
170+ */
122171export async function getContextBlock (
123172 elementText : string
124173) : Promise < ContextBlock > {
@@ -134,6 +183,17 @@ export async function getContextBlock(
134183 return block ;
135184}
136185
186+ /**
187+ * Creates a static select element for Slack app.
188+ *
189+ * @param placeholderText - The placeholder text to be displayed in the select element.
190+ * @param options - An array of options for the select element.
191+ * @param blockId - The ID of the block containing the select element.
192+ * @param actionId - The ID of the action associated with the select element.
193+ * @param initialValue - The initial value for the select element (optional).
194+ *
195+ * @returns A promise that resolves to a StaticSelectElement object.
196+ */
137197export async function getStaticSelectElement (
138198 placeholderText : string ,
139199 options : Array < Option > ,
@@ -156,6 +216,13 @@ export async function getStaticSelectElement(
156216 return block ;
157217}
158218
219+ /**
220+ * Retrieves an Option object with the provided text and value.
221+ *
222+ * @param {string } text - The text to be displayed for the option.
223+ * @param {string } value - The value associated with the option.
224+ * @returns {Promise<Option> } - A Promise that resolves to an Option object.
225+ */
159226export async function getOptions ( text : string , value : string ) : Promise < Option > {
160227 const block : Option = {
161228 text : { type : "plain_text" , text } ,
@@ -164,6 +231,13 @@ export async function getOptions(text: string, value: string): Promise<Option> {
164231 return block ;
165232}
166233
234+ /**
235+ * Retrieves an ActionsBlock with the specified blockId and elements.
236+ *
237+ * @param blockId - The unique identifier for the ActionsBlock.
238+ * @param elements - An array of ButtonElement, StaticSelectElement, or MultiStaticSelectElement objects.
239+ * @returns A Promise that resolves to an ActionsBlock.
240+ */
167241export async function getActionsBlock (
168242 blockId : string ,
169243 elements :
@@ -179,6 +253,15 @@ export async function getActionsBlock(
179253 return block ;
180254}
181255
256+ /**
257+ * Retrieves a multi-static select element with the specified placeholder text, options, block ID, and action ID.
258+ *
259+ * @param placeholderText - The text to be displayed as a placeholder in the multi-static select element.
260+ * @param options - An array of options for the multi-static select element.
261+ * @param blockId - The ID of the block containing the multi-static select element.
262+ * @param actionId - The ID of the action associated with the multi-static select element.
263+ * @returns A promise that resolves to a MultiStaticSelectElement object.
264+ */
182265export async function getMultiStaticElement (
183266 placeholderText : string ,
184267 options : Array < Option > ,
@@ -199,6 +282,15 @@ export async function getMultiStaticElement(
199282 return block ;
200283}
201284
285+ /**
286+ * Retrieves a checkbox element with the specified options, initial options, block ID, and action ID.
287+ *
288+ * @param options - An array of options for the checkbox element.
289+ * @param initialOptions - An array of initial options selected for the checkbox element.
290+ * @param blockId - The ID of the block containing the checkbox element.
291+ * @param actionId - The ID of the action associated with the checkbox element.
292+ * @returns A promise that resolves to a CheckboxElement object.
293+ */
202294export async function getCheckBoxElement (
203295 options : Array < Option > ,
204296 initialOptions : Array < Option > ,
@@ -216,6 +308,15 @@ export async function getCheckBoxElement(
216308 return block ;
217309}
218310
311+ /**
312+ * Retrieves a toggle switch element with the specified options, initial options, block ID, and action ID.
313+ *
314+ * @param options - An array of options for the toggle switch.
315+ * @param initialOptions - An array of initial options for the toggle switch.
316+ * @param blockId - The ID of the block.
317+ * @param actionId - The ID of the action.
318+ * @returns A promise that resolves to a ToggleSwitchElement.
319+ */
219320export async function getToggleSwitchElement (
220321 options : Array < Option > ,
221322 initialOptions : Array < Option > ,
0 commit comments