UNPKG

jsx-slack

Version:

Build JSON object for Slack Block Kit surfaces from JSX

53 lines (52 loc) 2.25 kB
import { JSXSlack } from '../../jsx'; import { BuiltInComponent } from '../../jsx-internals'; import { ConfirmableProps } from '../composition/Confirm'; import { InputComponentProps } from '../layout/Input'; import { ActionProps, AutoFocusibleProps, SingleSelectableProps, MultiSelectablePropsFrom } from './utils'; interface SingleSelectProps extends ActionProps, AutoFocusibleProps, ConfirmableProps, SingleSelectableProps { children: JSXSlack.ChildNodes; /** The placeholder text shown in select field. */ placeholder?: string; /** * A value of the initially selected option. * * It must choose a string of `value` prop from defined `<Option>` elements in * children. If not defined, an inital option will follow the state of * `<Option selected>`. */ value?: string | null; } interface MultiSelectProps extends MultiSelectablePropsFrom<SingleSelectProps, 'value'> { /** In multiple select, you can choose multiple values through array. */ value?: string | string[] | null; } export type SelectProps = InputComponentProps<SingleSelectProps | MultiSelectProps>; /** * The interactive component or input component for * [the `static_select` element](https://api.slack.com/reference/block-kit/block-elements#static_select) and * [the `multi_static_select` element](https://api.slack.com/reference/block-kit/block-elements#static_multi_select). * * Provide a menu element with static options by the similar interface to * `<select>` HTML element. It must contain elements either of `<Option>` or * `<Optgroup>` as immediate children. * * @example * ```jsx * <Blocks> * <Actions> * <Select actionId="rating" placeholder="Rate it!"> * <Option value="5">5 {':star:'.repeat(5)}</Option> * <Option value="4">4 {':star:'.repeat(4)}</Option> * <Option value="3">3 {':star:'.repeat(3)}</Option> * <Option value="2">2 {':star:'.repeat(2)}</Option> * <Option value="1">1 {':star:'.repeat(1)}</Option> * </Select> * </Actions> * </Blocks> * ``` * * @return The partial JSON of a block element for selecting from static * options, or `input` layout block with it */ export declare const Select: BuiltInComponent<SelectProps>; export {};