729 lines
No EOL
30 KiB
JavaScript
729 lines
No EOL
30 KiB
JavaScript
"use strict";
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = function (d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
var Enums = require("./enums");
|
|
var Utils = require("./utils");
|
|
var Shared = require("./shared");
|
|
var ColorDefinition = /** @class */ (function () {
|
|
function ColorDefinition(defaultColor, subtleColor) {
|
|
this.default = "#000000";
|
|
this.subtle = "#666666";
|
|
if (defaultColor) {
|
|
this.default = defaultColor;
|
|
}
|
|
if (subtleColor) {
|
|
this.subtle = subtleColor;
|
|
}
|
|
}
|
|
ColorDefinition.prototype.parse = function (obj) {
|
|
if (obj) {
|
|
this.default = obj["default"] || this.default;
|
|
this.subtle = obj["subtle"] || this.subtle;
|
|
}
|
|
};
|
|
return ColorDefinition;
|
|
}());
|
|
exports.ColorDefinition = ColorDefinition;
|
|
var TextColorDefinition = /** @class */ (function (_super) {
|
|
__extends(TextColorDefinition, _super);
|
|
function TextColorDefinition() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.highlightColors = new ColorDefinition("#22000000", "#11000000");
|
|
return _this;
|
|
}
|
|
TextColorDefinition.prototype.parse = function (obj) {
|
|
_super.prototype.parse.call(this, obj);
|
|
if (obj) {
|
|
this.highlightColors.parse(obj["highlightColors"]);
|
|
}
|
|
};
|
|
return TextColorDefinition;
|
|
}(ColorDefinition));
|
|
exports.TextColorDefinition = TextColorDefinition;
|
|
var AdaptiveCardConfig = /** @class */ (function () {
|
|
function AdaptiveCardConfig(obj) {
|
|
this.allowCustomStyle = false;
|
|
if (obj) {
|
|
this.allowCustomStyle = obj["allowCustomStyle"] || this.allowCustomStyle;
|
|
}
|
|
}
|
|
return AdaptiveCardConfig;
|
|
}());
|
|
exports.AdaptiveCardConfig = AdaptiveCardConfig;
|
|
var ImageSetConfig = /** @class */ (function () {
|
|
function ImageSetConfig(obj) {
|
|
this.imageSize = Enums.Size.Medium;
|
|
this.maxImageHeight = 100;
|
|
if (obj) {
|
|
this.imageSize = obj["imageSize"] != null ? obj["imageSize"] : this.imageSize;
|
|
this.maxImageHeight = Utils.getNumberValue(obj["maxImageHeight"], 100);
|
|
}
|
|
}
|
|
ImageSetConfig.prototype.toJSON = function () {
|
|
return {
|
|
imageSize: Enums.Size[this.imageSize],
|
|
maxImageHeight: this.maxImageHeight
|
|
};
|
|
};
|
|
return ImageSetConfig;
|
|
}());
|
|
exports.ImageSetConfig = ImageSetConfig;
|
|
var MediaConfig = /** @class */ (function () {
|
|
function MediaConfig(obj) {
|
|
this.allowInlinePlayback = true;
|
|
if (obj) {
|
|
this.defaultPoster = obj["defaultPoster"];
|
|
this.allowInlinePlayback = obj["allowInlinePlayback"] || this.allowInlinePlayback;
|
|
}
|
|
}
|
|
MediaConfig.prototype.toJSON = function () {
|
|
return {
|
|
defaultPoster: this.defaultPoster,
|
|
allowInlinePlayback: this.allowInlinePlayback
|
|
};
|
|
};
|
|
return MediaConfig;
|
|
}());
|
|
exports.MediaConfig = MediaConfig;
|
|
var FactTextDefinition = /** @class */ (function () {
|
|
function FactTextDefinition(obj) {
|
|
this.size = Enums.TextSize.Default;
|
|
this.color = Enums.TextColor.Default;
|
|
this.isSubtle = false;
|
|
this.weight = Enums.TextWeight.Default;
|
|
this.wrap = true;
|
|
if (obj) {
|
|
this.size = Utils.parseHostConfigEnum(Enums.TextSize, obj["size"], Enums.TextSize.Default);
|
|
this.color = Utils.parseHostConfigEnum(Enums.TextColor, obj["color"], Enums.TextColor.Default);
|
|
this.isSubtle = obj["isSubtle"] || this.isSubtle;
|
|
this.weight = Utils.parseHostConfigEnum(Enums.TextWeight, obj["weight"], this.getDefaultWeight());
|
|
this.wrap = obj["wrap"] != null ? obj["wrap"] : this.wrap;
|
|
}
|
|
}
|
|
;
|
|
FactTextDefinition.prototype.getDefaultWeight = function () {
|
|
return Enums.TextWeight.Default;
|
|
};
|
|
FactTextDefinition.prototype.toJSON = function () {
|
|
return {
|
|
size: Enums.TextSize[this.size],
|
|
color: Enums.TextColor[this.color],
|
|
isSubtle: this.isSubtle,
|
|
weight: Enums.TextWeight[this.weight],
|
|
wrap: this.wrap
|
|
};
|
|
};
|
|
return FactTextDefinition;
|
|
}());
|
|
exports.FactTextDefinition = FactTextDefinition;
|
|
var FactTitleDefinition = /** @class */ (function (_super) {
|
|
__extends(FactTitleDefinition, _super);
|
|
function FactTitleDefinition(obj) {
|
|
var _this = _super.call(this, obj) || this;
|
|
_this.maxWidth = 150;
|
|
_this.weight = Enums.TextWeight.Bolder;
|
|
if (obj) {
|
|
_this.maxWidth = obj["maxWidth"] != null ? obj["maxWidth"] : _this.maxWidth;
|
|
_this.weight = Utils.parseHostConfigEnum(Enums.TextWeight, obj["weight"], Enums.TextWeight.Bolder);
|
|
}
|
|
return _this;
|
|
}
|
|
FactTitleDefinition.prototype.getDefaultWeight = function () {
|
|
return Enums.TextWeight.Bolder;
|
|
};
|
|
return FactTitleDefinition;
|
|
}(FactTextDefinition));
|
|
exports.FactTitleDefinition = FactTitleDefinition;
|
|
var FactSetConfig = /** @class */ (function () {
|
|
function FactSetConfig(obj) {
|
|
this.title = new FactTitleDefinition();
|
|
this.value = new FactTextDefinition();
|
|
this.spacing = 10;
|
|
if (obj) {
|
|
this.title = new FactTitleDefinition(obj["title"]);
|
|
this.value = new FactTextDefinition(obj["value"]);
|
|
this.spacing = obj.spacing && obj.spacing != null ? obj.spacing && obj.spacing : this.spacing;
|
|
}
|
|
}
|
|
return FactSetConfig;
|
|
}());
|
|
exports.FactSetConfig = FactSetConfig;
|
|
var ShowCardActionConfig = /** @class */ (function () {
|
|
function ShowCardActionConfig(obj) {
|
|
this.actionMode = Enums.ShowCardActionMode.Inline;
|
|
this.inlineTopMargin = 16;
|
|
this.style = Enums.ContainerStyle.Emphasis;
|
|
if (obj) {
|
|
this.actionMode = Utils.parseHostConfigEnum(Enums.ShowCardActionMode, obj["actionMode"], Enums.ShowCardActionMode.Inline);
|
|
this.inlineTopMargin = obj["inlineTopMargin"] != null ? obj["inlineTopMargin"] : this.inlineTopMargin;
|
|
this.style = obj["style"] && typeof obj["style"] === "string" ? obj["style"] : Enums.ContainerStyle.Emphasis;
|
|
}
|
|
}
|
|
ShowCardActionConfig.prototype.toJSON = function () {
|
|
return {
|
|
actionMode: Enums.ShowCardActionMode[this.actionMode],
|
|
inlineTopMargin: this.inlineTopMargin,
|
|
style: this.style
|
|
};
|
|
};
|
|
return ShowCardActionConfig;
|
|
}());
|
|
exports.ShowCardActionConfig = ShowCardActionConfig;
|
|
var ActionsConfig = /** @class */ (function () {
|
|
function ActionsConfig(obj) {
|
|
this.maxActions = 5;
|
|
this.spacing = Enums.Spacing.Default;
|
|
this.buttonSpacing = 20;
|
|
this.showCard = new ShowCardActionConfig();
|
|
this.preExpandSingleShowCardAction = false;
|
|
this.actionsOrientation = Enums.Orientation.Horizontal;
|
|
this.actionAlignment = Enums.ActionAlignment.Left;
|
|
this.iconPlacement = Enums.ActionIconPlacement.LeftOfTitle;
|
|
this.allowTitleToWrap = false;
|
|
this.iconSize = 24;
|
|
if (obj) {
|
|
this.maxActions = obj["maxActions"] != null ? obj["maxActions"] : this.maxActions;
|
|
this.spacing = Utils.parseHostConfigEnum(Enums.Spacing, obj.spacing && obj.spacing, Enums.Spacing.Default);
|
|
this.buttonSpacing = obj["buttonSpacing"] != null ? obj["buttonSpacing"] : this.buttonSpacing;
|
|
this.showCard = new ShowCardActionConfig(obj["showCard"]);
|
|
this.preExpandSingleShowCardAction = Utils.getBoolValue(obj["preExpandSingleShowCardAction"], false);
|
|
this.actionsOrientation = Utils.parseHostConfigEnum(Enums.Orientation, obj["actionsOrientation"], Enums.Orientation.Horizontal);
|
|
this.actionAlignment = Utils.parseHostConfigEnum(Enums.ActionAlignment, obj["actionAlignment"], Enums.ActionAlignment.Left);
|
|
this.iconPlacement = Utils.parseHostConfigEnum(Enums.ActionIconPlacement, obj["iconPlacement"], Enums.ActionIconPlacement.LeftOfTitle);
|
|
this.allowTitleToWrap = obj["allowTitleToWrap"] != null ? obj["allowTitleToWrap"] : this.allowTitleToWrap;
|
|
try {
|
|
var sizeAndUnit = Shared.SizeAndUnit.parse(obj["iconSize"]);
|
|
if (sizeAndUnit.unit == Enums.SizeUnit.Pixel) {
|
|
this.iconSize = sizeAndUnit.physicalSize;
|
|
}
|
|
}
|
|
catch (e) {
|
|
// Swallow this, keep default icon size
|
|
}
|
|
}
|
|
}
|
|
ActionsConfig.prototype.toJSON = function () {
|
|
return {
|
|
maxActions: this.maxActions,
|
|
spacing: Enums.Spacing[this.spacing],
|
|
buttonSpacing: this.buttonSpacing,
|
|
showCard: this.showCard,
|
|
preExpandSingleShowCardAction: this.preExpandSingleShowCardAction,
|
|
actionsOrientation: Enums.Orientation[this.actionsOrientation],
|
|
actionAlignment: Enums.ActionAlignment[this.actionAlignment]
|
|
};
|
|
};
|
|
return ActionsConfig;
|
|
}());
|
|
exports.ActionsConfig = ActionsConfig;
|
|
var ColorSetDefinition = /** @class */ (function () {
|
|
function ColorSetDefinition(obj) {
|
|
this.default = new TextColorDefinition();
|
|
this.dark = new TextColorDefinition();
|
|
this.light = new TextColorDefinition();
|
|
this.accent = new TextColorDefinition();
|
|
this.good = new TextColorDefinition();
|
|
this.warning = new TextColorDefinition();
|
|
this.attention = new TextColorDefinition();
|
|
this.parse(obj);
|
|
}
|
|
ColorSetDefinition.prototype.parseSingleColor = function (obj, propertyName) {
|
|
if (obj) {
|
|
this[propertyName].parse(obj[propertyName]);
|
|
}
|
|
};
|
|
ColorSetDefinition.prototype.parse = function (obj) {
|
|
if (obj) {
|
|
this.parseSingleColor(obj, "default");
|
|
this.parseSingleColor(obj, "dark");
|
|
this.parseSingleColor(obj, "light");
|
|
this.parseSingleColor(obj, "accent");
|
|
this.parseSingleColor(obj, "good");
|
|
this.parseSingleColor(obj, "warning");
|
|
this.parseSingleColor(obj, "attention");
|
|
}
|
|
};
|
|
return ColorSetDefinition;
|
|
}());
|
|
exports.ColorSetDefinition = ColorSetDefinition;
|
|
var ContainerStyleDefinition = /** @class */ (function () {
|
|
function ContainerStyleDefinition(obj) {
|
|
this.foregroundColors = new ColorSetDefinition({
|
|
"default": { default: "#333333", subtle: "#EE333333" },
|
|
"dark": { default: "#000000", subtle: "#66000000" },
|
|
"light": { default: "#FFFFFF", subtle: "#33000000" },
|
|
"accent": { default: "#2E89FC", subtle: "#882E89FC" },
|
|
"good": { default: "#54A254", subtle: "#DD54A254" },
|
|
"warning": { default: "#E69500", subtle: "#DDE69500" },
|
|
"attention": { default: "#CC3300", subtle: "#DDCC3300" }
|
|
});
|
|
this.parse(obj);
|
|
}
|
|
ContainerStyleDefinition.prototype.parse = function (obj) {
|
|
if (obj) {
|
|
this.backgroundColor = obj["backgroundColor"];
|
|
this.foregroundColors.parse(obj["foregroundColors"]);
|
|
this.highlightBackgroundColor = obj["highlightBackgroundColor"];
|
|
this.highlightForegroundColor = obj["highlightForegroundColor"];
|
|
}
|
|
};
|
|
Object.defineProperty(ContainerStyleDefinition.prototype, "isBuiltIn", {
|
|
get: function () {
|
|
return false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ContainerStyleDefinition;
|
|
}());
|
|
exports.ContainerStyleDefinition = ContainerStyleDefinition;
|
|
var BuiltInContainerStyleDefinition = /** @class */ (function (_super) {
|
|
__extends(BuiltInContainerStyleDefinition, _super);
|
|
function BuiltInContainerStyleDefinition() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
Object.defineProperty(BuiltInContainerStyleDefinition.prototype, "isBuiltIn", {
|
|
get: function () {
|
|
return true;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return BuiltInContainerStyleDefinition;
|
|
}(ContainerStyleDefinition));
|
|
var ContainerStyleSet = /** @class */ (function () {
|
|
function ContainerStyleSet(obj) {
|
|
this._allStyles = {};
|
|
this._allStyles[Enums.ContainerStyle.Default] = new BuiltInContainerStyleDefinition();
|
|
this._allStyles[Enums.ContainerStyle.Emphasis] = new BuiltInContainerStyleDefinition();
|
|
this._allStyles[Enums.ContainerStyle.Accent] = new BuiltInContainerStyleDefinition();
|
|
this._allStyles[Enums.ContainerStyle.Good] = new BuiltInContainerStyleDefinition();
|
|
this._allStyles[Enums.ContainerStyle.Attention] = new BuiltInContainerStyleDefinition();
|
|
this._allStyles[Enums.ContainerStyle.Warning] = new BuiltInContainerStyleDefinition();
|
|
if (obj) {
|
|
this._allStyles[Enums.ContainerStyle.Default].parse(obj[Enums.ContainerStyle.Default]);
|
|
this._allStyles[Enums.ContainerStyle.Emphasis].parse(obj[Enums.ContainerStyle.Emphasis]);
|
|
this._allStyles[Enums.ContainerStyle.Accent].parse(obj[Enums.ContainerStyle.Accent]);
|
|
this._allStyles[Enums.ContainerStyle.Good].parse(obj[Enums.ContainerStyle.Good]);
|
|
this._allStyles[Enums.ContainerStyle.Attention].parse(obj[Enums.ContainerStyle.Attention]);
|
|
this._allStyles[Enums.ContainerStyle.Warning].parse(obj[Enums.ContainerStyle.Warning]);
|
|
var customStyleArray = obj["customStyles"];
|
|
if (customStyleArray && Array.isArray(customStyleArray)) {
|
|
for (var _i = 0, customStyleArray_1 = customStyleArray; _i < customStyleArray_1.length; _i++) {
|
|
var customStyle = customStyleArray_1[_i];
|
|
if (customStyle) {
|
|
var styleName = customStyle["name"];
|
|
if (styleName && typeof styleName === "string") {
|
|
if (this._allStyles.hasOwnProperty(styleName)) {
|
|
this._allStyles[styleName].parse(customStyle["style"]);
|
|
}
|
|
else {
|
|
this._allStyles[styleName] = new ContainerStyleDefinition(customStyle["style"]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ContainerStyleSet.prototype.toJSON = function () {
|
|
var _this = this;
|
|
var customStyleArray = [];
|
|
Object.keys(this._allStyles).forEach(function (key) {
|
|
if (!_this._allStyles[key].isBuiltIn) {
|
|
customStyleArray.push({
|
|
name: key,
|
|
style: _this._allStyles[key]
|
|
});
|
|
}
|
|
});
|
|
var result = {
|
|
default: this.default,
|
|
emphasis: this.emphasis
|
|
};
|
|
if (customStyleArray.length > 0) {
|
|
result.customStyles = customStyleArray;
|
|
}
|
|
return result;
|
|
};
|
|
ContainerStyleSet.prototype.getStyleByName = function (name, defaultValue) {
|
|
if (defaultValue === void 0) { defaultValue = null; }
|
|
return this._allStyles.hasOwnProperty(name) ? this._allStyles[name] : defaultValue;
|
|
};
|
|
Object.defineProperty(ContainerStyleSet.prototype, "default", {
|
|
get: function () {
|
|
return this._allStyles[Enums.ContainerStyle.Default];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ContainerStyleSet.prototype, "emphasis", {
|
|
get: function () {
|
|
return this._allStyles[Enums.ContainerStyle.Emphasis];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ContainerStyleSet;
|
|
}());
|
|
exports.ContainerStyleSet = ContainerStyleSet;
|
|
var Version = /** @class */ (function () {
|
|
function Version(major, minor, label) {
|
|
if (major === void 0) { major = 1; }
|
|
if (minor === void 0) { minor = 1; }
|
|
this._isValid = true;
|
|
this._major = major;
|
|
this._minor = minor;
|
|
this._label = label;
|
|
}
|
|
Version.parse = function (versionString, errors) {
|
|
if (!versionString) {
|
|
return null;
|
|
}
|
|
var result = new Version();
|
|
result._versionString = versionString;
|
|
var regEx = /(\d+).(\d+)/gi;
|
|
var matches = regEx.exec(versionString);
|
|
if (matches != null && matches.length == 3) {
|
|
result._major = parseInt(matches[1]);
|
|
result._minor = parseInt(matches[2]);
|
|
}
|
|
else {
|
|
result._isValid = false;
|
|
}
|
|
if (!result._isValid && errors) {
|
|
errors.push({
|
|
error: Enums.ValidationError.InvalidPropertyValue,
|
|
message: "Invalid version string: " + result._versionString
|
|
});
|
|
}
|
|
return result;
|
|
};
|
|
Version.prototype.toString = function () {
|
|
return !this._isValid ? this._versionString : this._major + "." + this._minor;
|
|
};
|
|
Version.prototype.compareTo = function (otherVersion) {
|
|
if (!this.isValid || !otherVersion.isValid) {
|
|
throw new Error("Cannot compare invalid version.");
|
|
}
|
|
if (this.major > otherVersion.major) {
|
|
return 1;
|
|
}
|
|
else if (this.major < otherVersion.major) {
|
|
return -1;
|
|
}
|
|
else if (this.minor > otherVersion.minor) {
|
|
return 1;
|
|
}
|
|
else if (this.minor < otherVersion.minor) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
};
|
|
Object.defineProperty(Version.prototype, "label", {
|
|
get: function () {
|
|
return this._label ? this._label : this.toString();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Version.prototype, "major", {
|
|
get: function () {
|
|
return this._major;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Version.prototype, "minor", {
|
|
get: function () {
|
|
return this._minor;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Version.prototype, "isValid", {
|
|
get: function () {
|
|
return this._isValid;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return Version;
|
|
}());
|
|
exports.Version = Version;
|
|
var HostCapabilities = /** @class */ (function () {
|
|
function HostCapabilities() {
|
|
this.capabilities = null;
|
|
}
|
|
HostCapabilities.prototype.setCapability = function (name, version) {
|
|
if (!this.capabilities) {
|
|
this.capabilities = {};
|
|
}
|
|
this.capabilities[name] = version;
|
|
};
|
|
HostCapabilities.prototype.parse = function (json, errors) {
|
|
if (json) {
|
|
for (var name_1 in json) {
|
|
var jsonVersion = json[name_1];
|
|
if (typeof jsonVersion === "string") {
|
|
if (jsonVersion == "*") {
|
|
this.setCapability(name_1, "*");
|
|
}
|
|
else {
|
|
var version = Version.parse(jsonVersion, errors);
|
|
if (version.isValid) {
|
|
this.setCapability(name_1, version);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
HostCapabilities.prototype.hasCapability = function (name, version) {
|
|
if (this.capabilities && this.capabilities.hasOwnProperty(name)) {
|
|
if (version == "*" || this.capabilities[name] == "*") {
|
|
return true;
|
|
}
|
|
return version.compareTo(this.capabilities[name]) <= 0;
|
|
}
|
|
return false;
|
|
};
|
|
HostCapabilities.prototype.areAllMet = function (hostCapabilities) {
|
|
if (this.capabilities) {
|
|
for (var capabilityName in this.capabilities) {
|
|
if (!hostCapabilities.hasCapability(capabilityName, this.capabilities[capabilityName])) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
return HostCapabilities;
|
|
}());
|
|
exports.HostCapabilities = HostCapabilities;
|
|
var FontTypeDefinition = /** @class */ (function () {
|
|
function FontTypeDefinition(fontFamily) {
|
|
this.fontFamily = "Segoe UI,Segoe,Segoe WP,Helvetica Neue,Helvetica,sans-serif";
|
|
this.fontSizes = {
|
|
small: 12,
|
|
default: 14,
|
|
medium: 17,
|
|
large: 21,
|
|
extraLarge: 26
|
|
};
|
|
this.fontWeights = {
|
|
lighter: 200,
|
|
default: 400,
|
|
bolder: 600
|
|
};
|
|
if (fontFamily) {
|
|
this.fontFamily = fontFamily;
|
|
}
|
|
}
|
|
FontTypeDefinition.prototype.parse = function (obj) {
|
|
this.fontFamily = obj["fontFamily"] || this.fontFamily;
|
|
this.fontSizes = {
|
|
small: obj.fontSizes && obj.fontSizes["small"] || this.fontSizes.small,
|
|
default: obj.fontSizes && obj.fontSizes["default"] || this.fontSizes.default,
|
|
medium: obj.fontSizes && obj.fontSizes["medium"] || this.fontSizes.medium,
|
|
large: obj.fontSizes && obj.fontSizes["large"] || this.fontSizes.large,
|
|
extraLarge: obj.fontSizes && obj.fontSizes["extraLarge"] || this.fontSizes.extraLarge
|
|
};
|
|
this.fontWeights = {
|
|
lighter: obj.fontWeights && obj.fontWeights["lighter"] || this.fontWeights.lighter,
|
|
default: obj.fontWeights && obj.fontWeights["default"] || this.fontWeights.default,
|
|
bolder: obj.fontWeights && obj.fontWeights["bolder"] || this.fontWeights.bolder
|
|
};
|
|
};
|
|
FontTypeDefinition.monospace = new FontTypeDefinition("'Courier New', Courier, monospace");
|
|
return FontTypeDefinition;
|
|
}());
|
|
exports.FontTypeDefinition = FontTypeDefinition;
|
|
var FontTypeSet = /** @class */ (function () {
|
|
function FontTypeSet(obj) {
|
|
this.default = new FontTypeDefinition();
|
|
this.monospace = new FontTypeDefinition("'Courier New', Courier, monospace");
|
|
if (obj) {
|
|
this.default.parse(obj["default"]);
|
|
this.monospace.parse(obj["monospace"]);
|
|
}
|
|
}
|
|
FontTypeSet.prototype.getStyleDefinition = function (style) {
|
|
switch (style) {
|
|
case Enums.FontType.Monospace:
|
|
return this.monospace;
|
|
case Enums.FontType.Default:
|
|
default:
|
|
return this.default;
|
|
}
|
|
};
|
|
return FontTypeSet;
|
|
}());
|
|
exports.FontTypeSet = FontTypeSet;
|
|
var HostConfig = /** @class */ (function () {
|
|
function HostConfig(obj) {
|
|
this.hostCapabilities = new HostCapabilities();
|
|
this.choiceSetInputValueSeparator = ",";
|
|
this.supportsInteractivity = true;
|
|
this.fontTypes = null;
|
|
this.spacing = {
|
|
small: 3,
|
|
default: 8,
|
|
medium: 20,
|
|
large: 30,
|
|
extraLarge: 40,
|
|
padding: 15
|
|
};
|
|
this.separator = {
|
|
lineThickness: 1,
|
|
lineColor: "#EEEEEE"
|
|
};
|
|
this.imageSizes = {
|
|
small: 40,
|
|
medium: 80,
|
|
large: 160
|
|
};
|
|
this.containerStyles = new ContainerStyleSet();
|
|
this.actions = new ActionsConfig();
|
|
this.adaptiveCard = new AdaptiveCardConfig();
|
|
this.imageSet = new ImageSetConfig();
|
|
this.media = new MediaConfig();
|
|
this.factSet = new FactSetConfig();
|
|
this.cssClassNamePrefix = null;
|
|
this.alwaysAllowBleed = false;
|
|
if (obj) {
|
|
if (typeof obj === "string" || obj instanceof String) {
|
|
obj = JSON.parse(obj);
|
|
}
|
|
this.choiceSetInputValueSeparator = (obj && typeof obj["choiceSetInputValueSeparator"] === "string") ? obj["choiceSetInputValueSeparator"] : this.choiceSetInputValueSeparator;
|
|
this.supportsInteractivity = (obj && typeof obj["supportsInteractivity"] === "boolean") ? obj["supportsInteractivity"] : this.supportsInteractivity;
|
|
this._legacyFontType = new FontTypeDefinition();
|
|
this._legacyFontType.parse(obj);
|
|
if (obj.fontTypes) {
|
|
this.fontTypes = new FontTypeSet(obj.fontTypes);
|
|
}
|
|
if (obj.lineHeights) {
|
|
this.lineHeights = {
|
|
small: obj.lineHeights["small"],
|
|
default: obj.lineHeights["default"],
|
|
medium: obj.lineHeights["medium"],
|
|
large: obj.lineHeights["large"],
|
|
extraLarge: obj.lineHeights["extraLarge"]
|
|
};
|
|
}
|
|
;
|
|
this.imageSizes = {
|
|
small: obj.imageSizes && obj.imageSizes["small"] || this.imageSizes.small,
|
|
medium: obj.imageSizes && obj.imageSizes["medium"] || this.imageSizes.medium,
|
|
large: obj.imageSizes && obj.imageSizes["large"] || this.imageSizes.large,
|
|
};
|
|
this.containerStyles = new ContainerStyleSet(obj["containerStyles"]);
|
|
this.spacing = {
|
|
small: obj.spacing && obj.spacing["small"] || this.spacing.small,
|
|
default: obj.spacing && obj.spacing["default"] || this.spacing.default,
|
|
medium: obj.spacing && obj.spacing["medium"] || this.spacing.medium,
|
|
large: obj.spacing && obj.spacing["large"] || this.spacing.large,
|
|
extraLarge: obj.spacing && obj.spacing["extraLarge"] || this.spacing.extraLarge,
|
|
padding: obj.spacing && obj.spacing["padding"] || this.spacing.padding
|
|
};
|
|
this.separator = {
|
|
lineThickness: obj.separator && obj.separator["lineThickness"] || this.separator.lineThickness,
|
|
lineColor: obj.separator && obj.separator["lineColor"] || this.separator.lineColor
|
|
};
|
|
this.actions = new ActionsConfig(obj.actions || this.actions);
|
|
this.adaptiveCard = new AdaptiveCardConfig(obj.adaptiveCard || this.adaptiveCard);
|
|
this.imageSet = new ImageSetConfig(obj["imageSet"]);
|
|
this.factSet = new FactSetConfig(obj["factSet"]);
|
|
}
|
|
}
|
|
HostConfig.prototype.getFontTypeDefinition = function (style) {
|
|
if (this.fontTypes) {
|
|
return this.fontTypes.getStyleDefinition(style);
|
|
}
|
|
else {
|
|
return style == Enums.FontType.Monospace ? FontTypeDefinition.monospace : this._legacyFontType;
|
|
}
|
|
};
|
|
HostConfig.prototype.getEffectiveSpacing = function (spacing) {
|
|
switch (spacing) {
|
|
case Enums.Spacing.Small:
|
|
return this.spacing.small;
|
|
case Enums.Spacing.Default:
|
|
return this.spacing.default;
|
|
case Enums.Spacing.Medium:
|
|
return this.spacing.medium;
|
|
case Enums.Spacing.Large:
|
|
return this.spacing.large;
|
|
case Enums.Spacing.ExtraLarge:
|
|
return this.spacing.extraLarge;
|
|
case Enums.Spacing.Padding:
|
|
return this.spacing.padding;
|
|
default:
|
|
return 0;
|
|
}
|
|
};
|
|
HostConfig.prototype.paddingDefinitionToSpacingDefinition = function (paddingDefinition) {
|
|
return new Shared.SpacingDefinition(this.getEffectiveSpacing(paddingDefinition.top), this.getEffectiveSpacing(paddingDefinition.right), this.getEffectiveSpacing(paddingDefinition.bottom), this.getEffectiveSpacing(paddingDefinition.left));
|
|
};
|
|
HostConfig.prototype.makeCssClassNames = function () {
|
|
var classNames = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
classNames[_i] = arguments[_i];
|
|
}
|
|
var result = [];
|
|
for (var _a = 0, classNames_1 = classNames; _a < classNames_1.length; _a++) {
|
|
var className = classNames_1[_a];
|
|
result.push((this.cssClassNamePrefix ? this.cssClassNamePrefix + "-" : "") + className);
|
|
}
|
|
return result;
|
|
};
|
|
HostConfig.prototype.makeCssClassName = function () {
|
|
var classNames = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
classNames[_i] = arguments[_i];
|
|
}
|
|
var result = this.makeCssClassNames.apply(this, classNames).join(" ");
|
|
return result ? result : "";
|
|
};
|
|
Object.defineProperty(HostConfig.prototype, "fontFamily", {
|
|
get: function () {
|
|
return this._legacyFontType.fontFamily;
|
|
},
|
|
set: function (value) {
|
|
this._legacyFontType.fontFamily = value;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(HostConfig.prototype, "fontSizes", {
|
|
get: function () {
|
|
return this._legacyFontType.fontSizes;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(HostConfig.prototype, "fontWeights", {
|
|
get: function () {
|
|
return this._legacyFontType.fontWeights;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return HostConfig;
|
|
}());
|
|
exports.HostConfig = HostConfig;
|
|
//# sourceMappingURL=host-config.js.map
|