@microsoft/teams.cards
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.cards" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.cards" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.cards?activeTab=code" ta
1 lines • 5.94 kB
Source Map (JSON)
{"version":3,"sources":["../../src/medias/text-run.ts"],"names":[],"mappings":"AAsEO,MAAM,OAA4B,CAAA;AAAA,EACvC,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,aAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA;AAAA,EAEA,WAAY,CAAA,IAAA,EAAc,OAA0B,GAAA,EAAI,EAAA;AACtD,IAAA,IAAA,CAAK,IAAO,GAAA,SAAA;AACZ,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AACZ,IAAO,MAAA,CAAA,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA;AAC7B,EAEA,OAAO,KAAK,OAAiC,EAAA;AAC3C,IAAA,OAAO,IAAI,OAAA,CAAQ,OAAQ,CAAA,IAAA,EAAM,OAAO,CAAA;AAAA;AAC1C,EAEA,UAAU,KAAc,EAAA;AACtB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,aAAa,KAAiB,EAAA;AAC5B,IAAA,IAAA,CAAK,QAAW,GAAA,KAAA;AAChB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,aAAA,CAAc,QAAQ,IAAM,EAAA;AAC1B,IAAA,IAAA,CAAK,SAAY,GAAA,KAAA;AACjB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,UAAA,CAAW,QAAQ,IAAM,EAAA;AACvB,IAAA,IAAA,CAAK,QAAW,GAAA,KAAA;AAChB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,UAAA,CAAW,QAAQ,IAAM,EAAA;AACvB,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;AACd,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,iBAAiB,KAAqB,EAAA;AACpC,IAAA,IAAA,CAAK,YAAe,GAAA,KAAA;AACpB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,SAAS,KAAiB,EAAA;AACxB,IAAA,IAAA,CAAK,IAAO,GAAA,KAAA;AACZ,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,iBAAA,CAAkB,QAAQ,IAAM,EAAA;AAC9B,IAAA,IAAA,CAAK,aAAgB,GAAA,KAAA;AACrB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,aAAA,CAAc,QAAQ,IAAM,EAAA;AAC1B,IAAA,IAAA,CAAK,SAAY,GAAA,KAAA;AACjB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,WAAW,KAAmB,EAAA;AAC5B,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;AACd,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,WAAW,KAAiB,EAAA;AAC1B,IAAK,IAAA,CAAA,IAAA,IAAQ,KAAM,CAAA,IAAA,CAAK,EAAE,CAAA;AAC1B,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,QAAW,GAAA;AACT,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEhB","file":"text-run.mjs","sourcesContent":["import { SelectAction } from '../actions';\nimport { Color, FontSize, FontType, FontWeight } from '../common';\n\n/**\n * Defines a single run of formatted text. A TextRun with no properties set can be represented in the json as string containing the text as a shorthand for the json object. These two representations are equivalent.\n */\nexport interface ITextRun {\n type: 'TextRun';\n\n /**\n * Text to display. Markdown is not supported.\n */\n text: string;\n\n /**\n * Controls the color of the text.\n */\n color?: Color;\n\n /**\n * The type of font to use\n */\n fontType?: FontType;\n\n /**\n * If true, displays the text highlighted.\n */\n highlight?: boolean;\n\n /**\n * If true, displays text slightly toned down to appear less prominent.\n */\n isSubtle?: boolean;\n\n /**\n * If true, displays the text using italic font.\n */\n italic?: boolean;\n\n /**\n * Action to invoke when this text run is clicked. Visually changes the text run into a hyperlink. Action.ShowCard is not supported.\n */\n selectAction?: SelectAction;\n\n /**\n * Controls size of text.\n */\n size?: FontSize;\n\n /**\n * If true, displays the text with strikethrough.\n */\n strikethrough?: boolean;\n\n /**\n * If true, displays the text with an underline.\n */\n underline?: boolean;\n\n /**\n * Controls the weight of the text.\n */\n weight?: FontWeight;\n}\n\nexport type TextRunOptions = Omit<ITextRun, 'type' | 'text'>;\n\n/**\n * Defines a single run of formatted text. A TextRun with no properties set can be represented in the json as string containing the text as a shorthand for the json object. These two representations are equivalent.\n */\nexport class TextRun implements ITextRun {\n type: 'TextRun';\n\n /**\n * Text to display. Markdown is not supported.\n */\n text: string;\n\n /**\n * Controls the color of the text.\n */\n color?: Color;\n\n /**\n * The type of font to use\n */\n fontType?: FontType;\n\n /**\n * If true, displays the text highlighted.\n */\n highlight?: boolean;\n\n /**\n * If true, displays text slightly toned down to appear less prominent.\n */\n isSubtle?: boolean;\n\n /**\n * If true, displays the text using italic font.\n */\n italic?: boolean;\n\n /**\n * Action to invoke when this text run is clicked. Visually changes the text run into a hyperlink. Action.ShowCard is not supported.\n */\n selectAction?: SelectAction;\n\n /**\n * Controls size of text.\n */\n size?: FontSize;\n\n /**\n * If true, displays the text with strikethrough.\n */\n strikethrough?: boolean;\n\n /**\n * If true, displays the text with an underline.\n */\n underline?: boolean;\n\n /**\n * Controls the weight of the text.\n */\n weight?: FontWeight;\n\n constructor(text: string, options: TextRunOptions = {}) {\n this.type = 'TextRun';\n this.text = text;\n Object.assign(this, options);\n }\n\n static from(options: Omit<ITextRun, 'type'>) {\n return new TextRun(options.text, options);\n }\n\n withColor(value: Color) {\n this.color = value;\n return this;\n }\n\n withFontType(value: FontType) {\n this.fontType = value;\n return this;\n }\n\n withHighlight(value = true) {\n this.highlight = value;\n return this;\n }\n\n withSubtle(value = true) {\n this.isSubtle = value;\n return this;\n }\n\n withItalic(value = true) {\n this.italic = value;\n return this;\n }\n\n withSelectAction(value: SelectAction) {\n this.selectAction = value;\n return this;\n }\n\n withSize(value: FontSize) {\n this.size = value;\n return this;\n }\n\n withStrikeThrough(value = true) {\n this.strikethrough = value;\n return this;\n }\n\n withUnderline(value = true) {\n this.underline = value;\n return this;\n }\n\n withWeight(value: FontWeight) {\n this.weight = value;\n return this;\n }\n\n addText(...value: string[]) {\n this.text += value.join('');\n return this;\n }\n\n toString() {\n return this.text;\n }\n}\n"]}