jsx-slack
Version:
Build JSON object for Slack Block Kit surfaces from JSX
65 lines (64 loc) • 2.74 kB
TypeScript
import { Option as OptionComposition } from '@slack/types';
import { JSXSlack } from '../../jsx';
import { BuiltInComponent } from '../../jsx-internals';
import { ConfirmableProps } from '../composition/Confirm';
import { OptionProps } from '../composition/Option';
import { InputComponentProps } from '../layout/Input';
import { ActionProps, AutoFocusibleProps, SingleSelectableProps, MultiSelectablePropsFrom } from './utils';
type OptionType = JSXSlack.Node<OptionProps> | OptionComposition;
interface SingleExternalSelectProps extends ActionProps, AutoFocusibleProps, ConfirmableProps, SingleSelectableProps {
children?: never;
/**
* An initial option _exactly_ matched to provided options from external
* source.
*
* It accepts the raw [option composition object](https://api.slack.com/reference/block-kit/composition-objects#option)
* or `<Option>` element.
*/
initialOption?: OptionType;
/**
* A length of typed characters to begin request to the external data source.
*/
minQueryLength?: number;
/** The placeholder text shown in select field. */
placeholder?: string;
/** An alias into `initialOption` prop. */
value?: OptionType;
}
interface MultiExternalSelectProps extends MultiSelectablePropsFrom<SingleExternalSelectProps, 'initialOption' | 'value'> {
/** In multiple select, you can set multiple values through array. */
initialOption?: OptionType | OptionType[];
value?: OptionType | OptionType[];
}
export type ExternalSelectProps = InputComponentProps<SingleExternalSelectProps | MultiExternalSelectProps>;
/**
* The interactive component or input component for
* [the `external_select` element](https://api.slack.com/reference/block-kit/block-elements#external_select) and
* [the `multi_external_select` element](https://api.slack.com/reference/block-kit/block-elements#external_multi_select).
*
* Provide a selectable menu element from dynamic options supplied by the
* external source.
*
* Slack app will need to set up the supplier of option elements first.
* [Learn about external source in Slack documentation.](https://api.slack.com/reference/block-kit/block-elements#external_select)
* `<SelectFragment>` component would be useful to supply dynamic options
* through JSX.
*
* @example
* ```jsx
* <Blocks>
* <Actions>
* <ExternalSelect
* actionId="category"
* placeholder="Select category..."
* minQueryLength={2}
* />
* </Actions>
* </Blocks>
* ```
*
* @return The partial JSON of a block element for selecting from the external
* data source, or `input` layout block with it
*/
export declare const ExternalSelect: BuiltInComponent<ExternalSelectProps>;
export {};