UNPKG

@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 4.96 kB
{"version":3,"sources":["../../src/medias/text-block.ts"],"names":[],"mappings":";;AA4DO,MAAM,kBAAkB,OAA8B,CAAA;AAAA,EAC3D,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA,EAEA,WAAY,CAAA,IAAA,EAAc,OAA4B,GAAA,EAAI,EAAA;AACxD,IAAM,KAAA,EAAA;AACN,IAAA,IAAA,CAAK,IAAO,GAAA,WAAA;AACZ,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AACZ,IAAO,MAAA,CAAA,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA;AAC7B,EAEA,OAAO,KAAK,OAAmC,EAAA;AAC7C,IAAA,OAAO,IAAI,SAAA,CAAU,OAAQ,CAAA,IAAA,EAAM,OAAO,CAAA;AAAA;AAC5C,EAEA,UAAU,KAA8B,EAAA;AACtC,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAO,OAAA,IAAA;AAAA;AACT,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,UAAA,CAAW,QAAQ,IAAM,EAAA;AACvB,IAAA,IAAA,CAAK,QAAW,GAAA,KAAA;AAChB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,aAAa,KAAe,EAAA;AAC1B,IAAA,IAAA,CAAK,QAAW,GAAA,KAAA;AAChB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,SAAS,KAAiB,EAAA;AACxB,IAAA,IAAA,CAAK,IAAO,GAAA,KAAA;AACZ,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,WAAW,KAAmB,EAAA;AAC5B,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;AACd,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,QAAA,CAAS,QAAQ,IAAM,EAAA;AACrB,IAAA,IAAA,CAAK,IAAO,GAAA,KAAA;AACZ,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-block.mjs","sourcesContent":["import { IElement, Element } from '../base';\nimport { Color, FontSize, FontType, FontWeight } from '../common';\n\n/**\n * Displays text, allowing control over font sizes, weight, and color.\n */\nexport interface ITextBlock extends IElement {\n type: 'TextBlock';\n\n /**\n * Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures)\n */\n text: string;\n\n /**\n * The style of this TextBlock for accessibility purposes.\n */\n style?: 'default' | 'heading';\n\n /**\n * Controls the color of TextBlock elements.\n */\n color?: Color;\n\n /**\n * Type of font to use for rendering\n */\n fontType?: FontType | null;\n\n /**\n * If true, displays text slightly toned down to appear less prominent.\n */\n isSubtle?: boolean;\n\n /**\n * Specifies the maximum number of lines to display.\n */\n maxLines?: number;\n\n /**\n * Controls size of text.\n */\n size?: FontSize;\n\n /**\n * Controls the weight of TextBlock elements.\n */\n weight?: FontWeight;\n\n /**\n * If true, allow text to wrap. Otherwise, text is clipped.\n */\n wrap?: boolean;\n}\n\nexport type TextBlockOptions = Omit<ITextBlock, 'type' | 'text'>;\n\n/**\n * Displays text, allowing control over font sizes, weight, and color.\n */\nexport class TextBlock extends Element implements ITextBlock {\n type: 'TextBlock';\n\n /**\n * Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures)\n */\n text: string;\n\n /**\n * The style of this TextBlock for accessibility purposes.\n */\n style?: 'default' | 'heading';\n\n /**\n * Controls the color of TextBlock elements.\n */\n color?: Color;\n\n /**\n * Type of font to use for rendering\n */\n fontType?: FontType | null;\n\n /**\n * If true, displays text slightly toned down to appear less prominent.\n */\n isSubtle?: boolean;\n\n /**\n * Specifies the maximum number of lines to display.\n */\n maxLines?: number;\n\n /**\n * Controls size of text.\n */\n size?: FontSize;\n\n /**\n * Controls the weight of TextBlock elements.\n */\n weight?: FontWeight;\n\n /**\n * If true, allow text to wrap. Otherwise, text is clipped.\n */\n wrap?: boolean;\n\n constructor(text: string, options: TextBlockOptions = {}) {\n super();\n this.type = 'TextBlock';\n this.text = text;\n Object.assign(this, options);\n }\n\n static from(options: Omit<ITextBlock, 'type'>) {\n return new TextBlock(options.text, options);\n }\n\n withStyle(value: 'default' | 'heading') {\n this.style = value;\n return this;\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 withSubtle(value = true) {\n this.isSubtle = value;\n return this;\n }\n\n withMaxLines(value: number) {\n this.maxLines = value;\n return this;\n }\n\n withSize(value: FontSize) {\n this.size = value;\n return this;\n }\n\n withWeight(value: FontWeight) {\n this.weight = value;\n return this;\n }\n\n withWrap(value = true) {\n this.wrap = 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"]}