UNPKG

speedybot

Version:

<p align="center"> <a href="https://github.com/valgaze/speedybot"> <img src="https://img.shields.io/npm/v/speedybot.svg" /> </a> <a href="https://github.com/valgaze/speedybot"> <img src="https://img.shields.io/npm/dm/speedybot.svg" /> </a>

195 lines (194 loc) 5.87 kB
import { Card } from "./index"; import { AttachedData } from "./types"; export declare type AbbreviatedSpeedyCard = { title: string; subTitle: string; image: string; url: string; urlLabel: string; data: AttachedData; chips: (string | { title: string; value?: string; })[]; table: string[][] | { [key: string]: string; }; choices: (string | number)[]; backgroundImage: string; }; export declare const checkers: { isSpeedyCard(input: SpeedyCard | object): boolean; isCard(cardCandidate: any | SpeedyCard): boolean; isEmail(candidate: string): boolean; }; export declare type SurveyQuestionType = "text" | "single-select" | "multi-select" | "picker-dropdown" | "picker-date" | "picker-time" | "textarea"; export declare type SurveyQuestion = { type: SurveyQuestionType; question: string; choices?: (string | number)[]; id?: string; }; export interface BaseConfig { title?: string; titleConfig?: Partial<TextBlock>; choices?: string[]; buttons?: string[]; } export interface BaseOpts { horizontalAlignment?: AlignmentChoices; size?: SizeChoices; } export interface ChoiceOption { title: string; value: string | number; } export interface ChoiceBlock { type?: string; id?: string; value?: string; isMultiSelect?: boolean; isVisible?: boolean; choices?: ChoiceOption[]; } export interface TextBlock extends BaseOpts { type: "TextBlock"; text: string; color?: ColorChoices; fontType?: string; isSubtle?: boolean; weight: "Lighter" | "Default" | "Bolder"; wrap?: boolean; } export interface ImageBlock extends BaseOpts { type: "Image"; url: string; selectAction?: { type: string; style?: string; isPrimary?: boolean; url: string; }; } export interface LinkButton { type: "Action.OpenUrl"; title: string; url: string; style?: "positive" | "destructive"; } export interface inputConfig { id?: string; placeholder?: string; isMultiline?: boolean; } export interface Fact { title: string; value: string; } export interface FactSet { type: "FactSet"; facts: Fact[]; } export declare type HeaderConfig = { iconURL?: string; backgroundColor?: ColorChoices; rtl?: boolean; iconAlignment?: AlignmentChoices; iconWidth?: number; iconRound?: boolean; textSize?: SizeChoices; textAlign?: AlignmentChoices; textColor?: ColorChoices; }; declare type LazyCardSpec = { $schema: string; type: string; version: string; body: unknown[]; actions?: any[]; backgroundImage?: string; }; export declare type SizeChoices = "Small" | "Default" | "Medium" | "Large" | "ExtraLarge" | "Stretch"; export declare type AlignmentChoices = "Left" | "Center" | "Right"; export declare type BaseColors = "Default" | "Dark" | "Light" | "Accent" | "Good" | "Warning" | "Attention"; export declare type SimpleColor = "blue" | "red" | "green" | "yellow"; export declare type ColorChoices = "Default" | "Dark" | "Light" | "Accent" | "Good" | "Warning" | "Attention" | "blue" | "red" | "green" | "yellow"; export declare type VAlignChoices = "Bottom" | "Center" | "Top"; export declare const SpeedyCardId: { dropdown: string; }; export declare class SpeedyCard { json: LazyCardSpec; tools: { checkColor(candidate: string): BaseColors; }; private _stash; private id; needsSubmit(): boolean; private checkId; constructor(); addTitle(title: string): this; addSubtitle(subTitle: string): this; addTable(input: (string | number)[][] | { [key: string]: string | number; }, separator?: boolean): this; addChip(payload: string | { title: string; value?: string; }, id?: string): this; addChips(chips: (string | { title: string; value?: string; })[], id?: string): this; addImage(url: string, config?: { size?: SizeChoices; align?: AlignmentChoices; targetURL?: string; }): this; addLink(url: string, label?: string): this; addLinkButton(url: string, label?: string): this; addText(text: string, config?: { bold?: boolean; size?: SizeChoices; align?: AlignmentChoices; color?: ColorChoices; backgroundColor?: ColorChoices; vertAlign?: VAlignChoices; }): this; addHeader(text: string, config?: HeaderConfig): this; addBlock(content: string | SpeedyCard, config?: { backgroundColor?: ColorChoices; vertAlign?: VAlignChoices; separator?: boolean; }): this; addSubcard(card: SpeedyCard | Card, textLabel?: string): this; addPickerDropdown(choices: (string | number | { title: string; value: number | string; })[], id?: string): this; addSingleSelect(choices: (string | number)[] | { title: string; value: string; }[], id?: string): this; addMultiSelect(choices: (string | number)[] | { title: string; value: string; }[], id?: string): this; private addSelect; addPickerDate(textLabel: string, id?: string): this; addPickerTime(textLabel: string, id?: string): this; addTextInput(placeholder: string, id?: string): this; addTextarea(placeholder: string, id?: string): this; setBackgroundImage(url: string): this; setSubmitButtonTitle(label: string): this; attachData(payload: AttachedData): this; private buildTextPayload; private addAction; addDeleteButton(label?: string): SpeedyCard; addButton(label: string, id?: string, attachedData?: string | { [key: string]: number | string | boolean; }): SpeedyCard; survey(questions: SurveyQuestion[], title?: string): SpeedyCard; build(): any; } export {};