UNPKG

@onereach/channel-transformer

Version:

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

53 lines (45 loc) 1.17 kB
import { IGenericInput } from '../../../generic/types'; import { ISlackInputText } from '../../types'; import { transformTextObject } from './helpers/transform-text-object'; export const transformPlainTextInput = ({ type, action_id, placeholder, initial_value, multiline, min_length, max_length, dispatch_action_config }: ISlackInputText): IGenericInput => { const res: IGenericInput = { type: 'input', props: { variableName: action_id, slack: { type } } }; if (initial_value) { res.props.value = initial_value; } if (placeholder) { res.props.placeholder = transformTextObject(placeholder).value; res.props.slack.placeholder_type = placeholder.type; res.props.slack.placeholder_emoji = placeholder.emoji; res.props.slack.placeholder_verbatim = placeholder.verbatim; } if (multiline) { res.props.multiline = multiline; } if (min_length) { res.props.minLength = min_length; } if (max_length) { res.props.maxLength = max_length; } if (dispatch_action_config) { res.props.slack.dispatch_action_config = dispatch_action_config; } return res; };