UNPKG

fox-block-builder

Version:

Maintainable code for loop slack-block-kit-like modal builder

130 lines (129 loc) 5.83 kB
import { Actionable, ChannelsSelect, Checkboxes, Confirmable, DateTimepicker, EmailInput, FileInput, Focusable, MultiChannelsSelect, MultiStaticSelect, MultiUsersSelect, NumberInput, Placeholdable, PlainTextElement, PlainTextInput, RadioButtons, StaticSelect, Timepicker, URLInput, UsersSelect } from '@slack/web-api'; import { DirectoryParams, FoxKnownBlock, OffsetParams, OffsetRangeParams, OneSSelectType, Prop, TImageSelectVariant, YearSinceParams } from '..'; import { FoxOption } from './bits.interfaces'; export interface FoxRadioButtons extends RadioButtons { options: FoxOption[]; } /** * @description Allows users to select a date from a calendar style UI. * @see {@link https://api.slack.com/reference/block-kit/block-elements#datepicker Date picker element reference}. * @see {@link https://api.slack.com/interactivity/handling This is an interactive component - see our guide to enabling interactivity}. */ export interface FoxDatepicker extends Actionable, Confirmable, Focusable, Placeholdable { /** * @description The type of element. In this case `type` is always `datepicker`. */ type: 'datepicker'; /** * @description The initial date that is selected when the element is loaded. * This should be in the format `YYYY-MM-DD`. */ initialOffset?: OffsetParams; [Prop.MinOffset]?: OffsetParams; [Prop.MaxOffset]?: OffsetParams; } /** * @description Allows users to select a date from a calendar style UI. * @see {@link https://api.slack.com/reference/block-kit/block-elements#datepicker Date picker element reference}. * @see {@link https://api.slack.com/interactivity/handling This is an interactive component - see our guide to enabling interactivity}. */ export interface FoxDateRangePicker extends Actionable, Confirmable, Focusable, Placeholdable { /** * @description The type of element. In this case `type` is always `date_range_picker`. */ type: 'date_range_picker'; /** * @description The initial date that is selected when the element is loaded. * This should be in the format `YYYY-MM-DD`. */ [Prop.InitialOffsetRange]?: OffsetRangeParams; [Prop.MinOffset]?: OffsetParams; [Prop.MaxOffset]?: OffsetParams; } export interface FoxStaticSelect extends StaticSelect { initial_option?: FoxOption; options?: FoxOption[]; option_groups?: { label: PlainTextElement; options: FoxOption[]; }[]; /** Года начиная с */ [Prop.YearSince]?: YearSinceParams; } export interface FoxMultiStaticSelect extends MultiStaticSelect { initial_option?: FoxOption; options?: FoxOption[]; option_groups?: { label: PlainTextElement; options: FoxOption[]; }[]; /** Года начиная с */ [Prop.YearSince]?: YearSinceParams; } export interface DirectorySelect extends Actionable, Confirmable, Focusable, Placeholdable { /** * @description The type of element. In this case `type` is always `static_select`. */ type: 'directory_select'; /** * @description A single option that exactly matches one of the options within `options` or `option_groups`. * This option will be selected when the menu initially loads. */ initial_option?: FoxOption; [Prop.Directory]: DirectoryParams; } export interface OneSSelect extends Actionable, Confirmable, Focusable, Placeholdable { /** * @description The type of element. In this case `type` is always `static_select`. */ type: 'one_s_select'; /** * @description A single option that exactly matches one of the options within `options` or `option_groups`. * This option will be selected when the menu initially loads. */ initial_option?: FoxOption; [Prop.OneSType]: OneSSelectType; } export interface ImageSelect extends Actionable, Confirmable, Focusable, Placeholdable { type: 'image_select'; initial_option?: FoxOption; options?: FoxOption[]; option_groups?: { label: PlainTextElement; options: FoxOption[]; }[]; variant: TImageSelectVariant; } /** * @description Allows users to enter freeform text data into a single-line or multi-line field. * @see {@link https://api.slack.com/reference/block-kit/block-elements#input Plain-text input element reference}. * @see {@link https://api.slack.com/interactivity/handling This is an interactive component - see our guide to enabling interactivity}. */ export interface FoxPlainTextInput extends PlainTextInput { /** Регекс для валидации */ [Prop.RegExp]?: RegExp; } export interface AddableInput extends Actionable, Confirmable, Focusable { type: 'addable'; /** @description An array of {@link AnyBlock} that defines the content of the view. Max of 100 blocks. */ blocks: FoxKnownBlock[]; /** * @description A single option that exactly matches one of the options within `options` or `option_groups`. * This option will be selected when the menu initially loads. */ initial_option?: FoxOption; [Prop.OneSType]: OneSSelectType; /** * @description The initial value in the input when it is loaded. */ initial_value?: string; /** * @description The minimum value, cannot be greater than `max_value`. */ min_value?: string; /** * @description The maximum value, cannot be less than `min_value`. */ max_value?: string; } export type FoxInputBlockElement = Checkboxes | FoxDatepicker | FoxDateRangePicker | DateTimepicker | EmailInput | FileInput | NumberInput | FoxPlainTextInput | FoxRadioButtons | Timepicker | URLInput | UsersSelect | FoxStaticSelect | ChannelsSelect | MultiUsersSelect | FoxMultiStaticSelect | MultiChannelsSelect | OneSSelect | DirectorySelect | ImageSelect | AddableInput;