Merged PR 760071: Fix issue of config changing and add removing sample card in web tool

Fix issue of config changing
add removing sample card in web tool
This commit is contained in:
Haobin Guo 2018-09-07 08:49:25 +00:00
Родитель c0bdfd505d
Коммит 3996e31dc1
20 изменённых файлов: 720 добавлений и 600 удалений

260
dist/Config/Types.js поставляемый
Просмотреть файл

@ -13,14 +13,14 @@ export class SpacingConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
padding: current.padding !== undefined ? current.padding : prev.padding,
};
let combined = new SpacingConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
combined.padding = current.padding !== undefined ? current.padding : prev.padding;
return combined;
}
return prev;
}, this);
@ -40,11 +40,11 @@ export class SeparatorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
thickness: current.thickness !== undefined ? current.thickness : prev.thickness,
color: current.color !== undefined ? current.color : prev.color,
spacing: current.spacing !== undefined ? current.spacing : prev.spacing,
};
let combined = new SeparatorConfig();
combined.thickness = current.thickness !== undefined ? current.thickness : prev.thickness;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.spacing = current.spacing !== undefined ? current.spacing : prev.spacing;
return combined;
}
return prev;
}, this);
@ -66,13 +66,13 @@ export class FontSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
};
let combined = new FontSizeConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
return combined;
}
return prev;
}, this);
@ -92,11 +92,11 @@ export class FontWeightConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
lighter: current.lighter !== undefined ? current.lighter : prev.lighter,
bolder: current.bolder !== undefined ? current.bolder : prev.bolder,
};
let combined = new FontWeightConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.lighter = current.lighter !== undefined ? current.lighter : prev.lighter;
combined.bolder = current.bolder !== undefined ? current.bolder : prev.bolder;
return combined;
}
return prev;
}, this);
@ -115,10 +115,10 @@ export class ColorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
subtle: current.subtle !== undefined ? current.subtle : prev.subtle,
};
let combined = new ColorConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.subtle = current.subtle !== undefined ? current.subtle : prev.subtle;
return combined;
}
return prev;
}, this);
@ -142,15 +142,15 @@ export class ColorSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
dark: prev.default !== undefined ? prev.dark.combine(current.dark) : current.dark,
light: prev.light !== undefined ? prev.light.combine(current.light) : current.light,
accent: prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent,
attention: prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention,
good: prev.good !== undefined ? prev.good.combine(current.good) : current.good,
warning: prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning,
};
let combined = new ColorSetConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.dark = prev.dark !== undefined ? prev.dark.combine(current.dark) : current.dark;
combined.light = prev.light !== undefined ? prev.light.combine(current.light) : current.light;
combined.accent = prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent;
combined.attention = prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention;
combined.good = prev.good !== undefined ? prev.good.combine(current.good) : current.good;
combined.warning = prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning;
return combined;
}
return prev;
}, this);
@ -169,10 +169,10 @@ export class ThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
background: current.background !== undefined ? current.background : prev.background,
foreground: prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground,
};
let combined = new ThemeConfig();
combined.background = current.background !== undefined ? current.background : prev.background;
combined.foreground = prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground;
return combined;
}
return prev;
}, this);
@ -191,10 +191,10 @@ export class ContainerConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new ContainerConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -214,11 +214,11 @@ export class ImageSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
};
let combined = new ImageSizeConfig();
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
return combined;
}
return prev;
}, this);
@ -238,11 +238,11 @@ export class ShowCardActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
mode: current.mode !== undefined ? current.mode : prev.mode,
margin: current.margin !== undefined ? current.margin : prev.margin,
style: current.style !== undefined ? current.style : prev.style,
};
let combined = new ShowCardActionConfig();
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
combined.style = current.style !== undefined ? current.style : prev.style;
return combined;
}
return prev;
}, this);
@ -268,17 +268,17 @@ export class ActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
capacity: current.capacity !== undefined ? current.capacity : prev.capacity,
actionSetSpacing: current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing,
actionSpacing: current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing,
showCard: prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard,
cardExpanding: current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding,
direction: current.direction !== undefined ? current.direction : prev.direction,
align: current.align !== undefined ? current.align : prev.align,
iconPosition: current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition,
iconSize: current.iconSize !== undefined ? current.iconSize : prev.iconSize,
};
let combined = new ActionConfig();
combined.capacity = current.capacity !== undefined ? current.capacity : prev.capacity;
combined.actionSetSpacing = current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing;
combined.actionSpacing = current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing;
combined.showCard = prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard;
combined.cardExpanding = current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding;
combined.direction = current.direction !== undefined ? current.direction : prev.direction;
combined.align = current.align !== undefined ? current.align : prev.align;
combined.iconPosition = current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition;
combined.iconSize = current.iconSize !== undefined ? current.iconSize : prev.iconSize;
return combined;
}
return prev;
}, this);
@ -296,9 +296,9 @@ export class CardConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
allowCustomStyle: current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle,
};
let combined = new CardConfig();
combined.allowCustomStyle = current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle;
return combined;
}
return prev;
}, this);
@ -317,10 +317,10 @@ export class ImageSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
imageSize: current.imageSize !== undefined ? current.imageSize : prev.imageSize,
maxImageHeight: current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight,
};
let combined = new ImageSetConfig();
combined.imageSize = current.imageSize !== undefined ? current.imageSize : prev.imageSize;
combined.maxImageHeight = current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight;
return combined;
}
return prev;
}, this);
@ -343,13 +343,13 @@ export class FactValueConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
};
let combined = new FactValueConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
return combined;
}
return prev;
}, this);
@ -372,14 +372,14 @@ export class FactTitleConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
maxWidth: current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth,
};
let combined = new FactTitleConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
combined.maxWidth = current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth;
return combined;
}
return prev;
}, this);
@ -399,11 +399,11 @@ export class FactSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
title: prev.title !== undefined ? prev.title.combine(current.title) : current.title,
value: prev.value !== undefined ? prev.value.combine(current.value) : current.value,
margin: current.margin !== undefined ? current.margin : prev.margin,
};
let combined = new FactSetConfig();
combined.title = prev.title !== undefined ? prev.title.combine(current.title) : current.title;
combined.value = prev.value !== undefined ? prev.value.combine(current.value) : current.value;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
return combined;
}
return prev;
}, this);
@ -426,14 +426,15 @@ export class InputThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
color: current.color !== undefined ? current.color : prev.color,
focusColor: current.focusColor !== undefined ? current.focusColor : prev.focusColor,
backgroundColor: current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor,
focusBackgroundColor: current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor,
borderColor: current.borderColor !== undefined ? current.borderColor : prev.borderColor,
focusBorderColor: current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor,
};
let combined = new InputThemeConfig();
combined.color = current.color !== undefined ? current.color : prev.color;
combined.focusColor = current.focusColor !== undefined ? current.focusColor : prev.focusColor;
combined.backgroundColor = current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor;
combined.focusBackgroundColor =
current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor;
combined.borderColor = current.borderColor !== undefined ? current.borderColor : prev.borderColor;
combined.focusBorderColor = current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor;
return combined;
}
return prev;
}, this);
@ -452,10 +453,10 @@ export class InputConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new InputConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -474,10 +475,10 @@ export class MediaConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
defaultPosterUrl: current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl,
playButtonUrl: current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl,
};
let combined = new MediaConfig();
combined.defaultPosterUrl = current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl;
combined.playButtonUrl = current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl;
return combined;
}
return prev;
}, this);
@ -509,25 +510,26 @@ export class HostConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
spacing: prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing,
separator: prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator,
supportInteractive: current.supportInteractive !== undefined ? current.supportInteractive : prev.supportInteractive,
fontFamily: current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily,
fontSize: prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize,
fontWeight: prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight,
container: prev.container !== undefined ?
prev.container.combine(current.container) :
current.container,
imageSize: prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize,
action: prev.action !== undefined ? prev.action.combine(current.action) : current.action,
card: prev.card !== undefined ? prev.card.combine(current.card) : current.card,
imageSet: prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet,
factSet: prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet,
media: prev.media !== undefined ? prev.media.combine(current.media) : current.media,
input: prev.input !== undefined ? prev.input.combine(current.input) : current.input,
mode: current.mode !== undefined ? current.mode : prev.mode,
};
let combined = new HostConfig();
combined.spacing = prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing;
combined.separator = prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator;
combined.supportInteractive = current.supportInteractive !== undefined ?
current.supportInteractive : prev.supportInteractive;
combined.fontFamily = current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily;
combined.fontSize = prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize;
combined.fontWeight = prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight;
combined.container = prev.container !== undefined ?
prev.container.combine(current.container) :
current.container;
combined.imageSize = prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize;
combined.action = prev.action !== undefined ? prev.action.combine(current.action) : current.action;
combined.card = prev.card !== undefined ? prev.card.combine(current.card) : current.card;
combined.imageSet = prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet;
combined.factSet = prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet;
combined.media = prev.media !== undefined ? prev.media.combine(current.media) : current.media;
combined.input = prev.input !== undefined ? prev.input.combine(current.input) : current.input;
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
return combined;
}
return prev;
}, this);

5
dist/Contexts/HostContext.js поставляемый
Просмотреть файл

@ -10,11 +10,12 @@ export class HostContext {
return this.sharedInstance;
}
applyConfig(config) {
const parsedConfig = ConfigManager.parseConfig(config);
if (this.config) {
this.config = this.config.combine(config);
this.config = this.config.combine(parsedConfig);
}
else {
this.config = config;
this.config = parsedConfig;
}
}
getConfig() {

11
dist/Views/Root.js поставляемый
Просмотреть файл

@ -4,7 +4,7 @@ import { CardContext } from '../Contexts/CardContext';
import { HostContext } from '../Contexts/HostContext';
import { CardModel } from '../Models/Cards/Card';
import { AdaptiveCardView } from './Cards/AdaptiveCard';
export class CardRootView extends React.PureComponent {
export class CardRootView extends React.Component {
constructor(props) {
super(props);
let hostContext = HostContext.getInstance();
@ -19,6 +19,15 @@ export class CardRootView extends React.PureComponent {
this.rootCardContext.registerInfoHandler(this.props.onInfo);
this.rootCardContext.registerWarningHandler(this.props.onWarning);
}
shouldComponentUpdate(nextProps) {
if (JSON.stringify(nextProps) !== JSON.stringify(this.props)) {
if (JSON.stringify(nextProps.config) !== JSON.stringify(this.props.config)) {
HostContext.getInstance().applyConfig(nextProps.config);
}
return true;
}
return false;
}
render() {
return (React.createElement(View, { style: { flex: 1 } },
React.createElement(AdaptiveCardView, { index: 0, model: new CardModel(this.props.adaptiveCard, undefined, this.rootCardContext), theme: 'default', style: this.props.style })));

Просмотреть файл

@ -13,14 +13,14 @@ export class SpacingConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
padding: current.padding !== undefined ? current.padding : prev.padding,
};
let combined = new SpacingConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
combined.padding = current.padding !== undefined ? current.padding : prev.padding;
return combined;
}
return prev;
}, this);
@ -40,11 +40,11 @@ export class SeparatorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
thickness: current.thickness !== undefined ? current.thickness : prev.thickness,
color: current.color !== undefined ? current.color : prev.color,
spacing: current.spacing !== undefined ? current.spacing : prev.spacing,
};
let combined = new SeparatorConfig();
combined.thickness = current.thickness !== undefined ? current.thickness : prev.thickness;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.spacing = current.spacing !== undefined ? current.spacing : prev.spacing;
return combined;
}
return prev;
}, this);
@ -66,13 +66,13 @@ export class FontSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
};
let combined = new FontSizeConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
return combined;
}
return prev;
}, this);
@ -92,11 +92,11 @@ export class FontWeightConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
lighter: current.lighter !== undefined ? current.lighter : prev.lighter,
bolder: current.bolder !== undefined ? current.bolder : prev.bolder,
};
let combined = new FontWeightConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.lighter = current.lighter !== undefined ? current.lighter : prev.lighter;
combined.bolder = current.bolder !== undefined ? current.bolder : prev.bolder;
return combined;
}
return prev;
}, this);
@ -115,10 +115,10 @@ export class ColorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
subtle: current.subtle !== undefined ? current.subtle : prev.subtle,
};
let combined = new ColorConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.subtle = current.subtle !== undefined ? current.subtle : prev.subtle;
return combined;
}
return prev;
}, this);
@ -142,15 +142,15 @@ export class ColorSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
dark: prev.default !== undefined ? prev.dark.combine(current.dark) : current.dark,
light: prev.light !== undefined ? prev.light.combine(current.light) : current.light,
accent: prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent,
attention: prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention,
good: prev.good !== undefined ? prev.good.combine(current.good) : current.good,
warning: prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning,
};
let combined = new ColorSetConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.dark = prev.dark !== undefined ? prev.dark.combine(current.dark) : current.dark;
combined.light = prev.light !== undefined ? prev.light.combine(current.light) : current.light;
combined.accent = prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent;
combined.attention = prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention;
combined.good = prev.good !== undefined ? prev.good.combine(current.good) : current.good;
combined.warning = prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning;
return combined;
}
return prev;
}, this);
@ -169,10 +169,10 @@ export class ThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
background: current.background !== undefined ? current.background : prev.background,
foreground: prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground,
};
let combined = new ThemeConfig();
combined.background = current.background !== undefined ? current.background : prev.background;
combined.foreground = prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground;
return combined;
}
return prev;
}, this);
@ -191,10 +191,10 @@ export class ContainerConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new ContainerConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -214,11 +214,11 @@ export class ImageSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
};
let combined = new ImageSizeConfig();
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
return combined;
}
return prev;
}, this);
@ -238,11 +238,11 @@ export class ShowCardActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
mode: current.mode !== undefined ? current.mode : prev.mode,
margin: current.margin !== undefined ? current.margin : prev.margin,
style: current.style !== undefined ? current.style : prev.style,
};
let combined = new ShowCardActionConfig();
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
combined.style = current.style !== undefined ? current.style : prev.style;
return combined;
}
return prev;
}, this);
@ -268,17 +268,17 @@ export class ActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
capacity: current.capacity !== undefined ? current.capacity : prev.capacity,
actionSetSpacing: current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing,
actionSpacing: current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing,
showCard: prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard,
cardExpanding: current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding,
direction: current.direction !== undefined ? current.direction : prev.direction,
align: current.align !== undefined ? current.align : prev.align,
iconPosition: current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition,
iconSize: current.iconSize !== undefined ? current.iconSize : prev.iconSize,
};
let combined = new ActionConfig();
combined.capacity = current.capacity !== undefined ? current.capacity : prev.capacity;
combined.actionSetSpacing = current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing;
combined.actionSpacing = current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing;
combined.showCard = prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard;
combined.cardExpanding = current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding;
combined.direction = current.direction !== undefined ? current.direction : prev.direction;
combined.align = current.align !== undefined ? current.align : prev.align;
combined.iconPosition = current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition;
combined.iconSize = current.iconSize !== undefined ? current.iconSize : prev.iconSize;
return combined;
}
return prev;
}, this);
@ -296,9 +296,9 @@ export class CardConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
allowCustomStyle: current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle,
};
let combined = new CardConfig();
combined.allowCustomStyle = current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle;
return combined;
}
return prev;
}, this);
@ -317,10 +317,10 @@ export class ImageSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
imageSize: current.imageSize !== undefined ? current.imageSize : prev.imageSize,
maxImageHeight: current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight,
};
let combined = new ImageSetConfig();
combined.imageSize = current.imageSize !== undefined ? current.imageSize : prev.imageSize;
combined.maxImageHeight = current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight;
return combined;
}
return prev;
}, this);
@ -343,13 +343,13 @@ export class FactValueConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
};
let combined = new FactValueConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
return combined;
}
return prev;
}, this);
@ -372,14 +372,14 @@ export class FactTitleConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
maxWidth: current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth,
};
let combined = new FactTitleConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
combined.maxWidth = current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth;
return combined;
}
return prev;
}, this);
@ -399,11 +399,11 @@ export class FactSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
title: prev.title !== undefined ? prev.title.combine(current.title) : current.title,
value: prev.value !== undefined ? prev.value.combine(current.value) : current.value,
margin: current.margin !== undefined ? current.margin : prev.margin,
};
let combined = new FactSetConfig();
combined.title = prev.title !== undefined ? prev.title.combine(current.title) : current.title;
combined.value = prev.value !== undefined ? prev.value.combine(current.value) : current.value;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
return combined;
}
return prev;
}, this);
@ -426,14 +426,15 @@ export class InputThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
color: current.color !== undefined ? current.color : prev.color,
focusColor: current.focusColor !== undefined ? current.focusColor : prev.focusColor,
backgroundColor: current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor,
focusBackgroundColor: current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor,
borderColor: current.borderColor !== undefined ? current.borderColor : prev.borderColor,
focusBorderColor: current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor,
};
let combined = new InputThemeConfig();
combined.color = current.color !== undefined ? current.color : prev.color;
combined.focusColor = current.focusColor !== undefined ? current.focusColor : prev.focusColor;
combined.backgroundColor = current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor;
combined.focusBackgroundColor =
current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor;
combined.borderColor = current.borderColor !== undefined ? current.borderColor : prev.borderColor;
combined.focusBorderColor = current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor;
return combined;
}
return prev;
}, this);
@ -452,10 +453,10 @@ export class InputConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new InputConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -474,10 +475,10 @@ export class MediaConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
defaultPosterUrl: current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl,
playButtonUrl: current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl,
};
let combined = new MediaConfig();
combined.defaultPosterUrl = current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl;
combined.playButtonUrl = current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl;
return combined;
}
return prev;
}, this);
@ -509,25 +510,26 @@ export class HostConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
spacing: prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing,
separator: prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator,
supportInteractive: current.supportInteractive !== undefined ? current.supportInteractive : prev.supportInteractive,
fontFamily: current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily,
fontSize: prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize,
fontWeight: prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight,
container: prev.container !== undefined ?
prev.container.combine(current.container) :
current.container,
imageSize: prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize,
action: prev.action !== undefined ? prev.action.combine(current.action) : current.action,
card: prev.card !== undefined ? prev.card.combine(current.card) : current.card,
imageSet: prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet,
factSet: prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet,
media: prev.media !== undefined ? prev.media.combine(current.media) : current.media,
input: prev.input !== undefined ? prev.input.combine(current.input) : current.input,
mode: current.mode !== undefined ? current.mode : prev.mode,
};
let combined = new HostConfig();
combined.spacing = prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing;
combined.separator = prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator;
combined.supportInteractive = current.supportInteractive !== undefined ?
current.supportInteractive : prev.supportInteractive;
combined.fontFamily = current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily;
combined.fontSize = prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize;
combined.fontWeight = prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight;
combined.container = prev.container !== undefined ?
prev.container.combine(current.container) :
current.container;
combined.imageSize = prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize;
combined.action = prev.action !== undefined ? prev.action.combine(current.action) : current.action;
combined.card = prev.card !== undefined ? prev.card.combine(current.card) : current.card;
combined.imageSet = prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet;
combined.factSet = prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet;
combined.media = prev.media !== undefined ? prev.media.combine(current.media) : current.media;
combined.input = prev.input !== undefined ? prev.input.combine(current.input) : current.input;
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
return combined;
}
return prev;
}, this);

Просмотреть файл

@ -10,11 +10,12 @@ export class HostContext {
return this.sharedInstance;
}
applyConfig(config) {
const parsedConfig = ConfigManager.parseConfig(config);
if (this.config) {
this.config = this.config.combine(config);
this.config = this.config.combine(parsedConfig);
}
else {
this.config = config;
this.config = parsedConfig;
}
}
getConfig() {

Просмотреть файл

@ -4,7 +4,7 @@ import { CardContext } from '../Contexts/CardContext';
import { HostContext } from '../Contexts/HostContext';
import { CardModel } from '../Models/Cards/Card';
import { AdaptiveCardView } from './Cards/AdaptiveCard';
export class CardRootView extends React.PureComponent {
export class CardRootView extends React.Component {
constructor(props) {
super(props);
let hostContext = HostContext.getInstance();
@ -19,6 +19,15 @@ export class CardRootView extends React.PureComponent {
this.rootCardContext.registerInfoHandler(this.props.onInfo);
this.rootCardContext.registerWarningHandler(this.props.onWarning);
}
shouldComponentUpdate(nextProps) {
if (JSON.stringify(nextProps) !== JSON.stringify(this.props)) {
if (JSON.stringify(nextProps.config) !== JSON.stringify(this.props.config)) {
HostContext.getInstance().applyConfig(nextProps.config);
}
return true;
}
return false;
}
render() {
return (React.createElement(View, { style: { flex: 1 } },
React.createElement(AdaptiveCardView, { index: 0, model: new CardModel(this.props.adaptiveCard, undefined, this.rootCardContext), theme: 'default', style: this.props.style })));

Просмотреть файл

@ -23,14 +23,14 @@ export class SpacingConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
padding: current.padding !== undefined ? current.padding : prev.padding,
} as SpacingConfig;
let combined = new SpacingConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
combined.padding = current.padding !== undefined ? current.padding : prev.padding;
return combined;
}
return prev;
}, this);
@ -56,11 +56,11 @@ export class SeparatorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
thickness: current.thickness !== undefined ? current.thickness : prev.thickness,
color: current.color !== undefined ? current.color : prev.color,
spacing: current.spacing !== undefined ? current.spacing : prev.spacing,
} as SeparatorConfig;
let combined = new SeparatorConfig();
combined.thickness = current.thickness !== undefined ? current.thickness : prev.thickness;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.spacing = current.spacing !== undefined ? current.spacing : prev.spacing;
return combined;
}
return prev;
}, this);
@ -90,13 +90,13 @@ export class FontSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
} as FontSizeConfig;
let combined = new FontSizeConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
return combined;
}
return prev;
}, this);
@ -124,11 +124,11 @@ export class FontWeightConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
lighter: current.lighter !== undefined ? current.lighter : prev.lighter,
bolder: current.bolder !== undefined ? current.bolder : prev.bolder,
} as FontWeightConfig;
let combined = new FontWeightConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.lighter = current.lighter !== undefined ? current.lighter : prev.lighter;
combined.bolder = current.bolder !== undefined ? current.bolder : prev.bolder;
return combined;
}
return prev;
}, this);
@ -152,10 +152,10 @@ export class ColorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
subtle: current.subtle !== undefined ? current.subtle : prev.subtle,
} as ColorConfig;
let combined = new ColorConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.subtle = current.subtle !== undefined ? current.subtle : prev.subtle;
return combined;
}
return prev;
}, this);
@ -189,15 +189,15 @@ export class ColorSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
dark: prev.default !== undefined ? prev.dark.combine(current.dark) : current.dark,
light: prev.light !== undefined ? prev.light.combine(current.light) : current.light,
accent: prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent,
attention: prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention,
good: prev.good !== undefined ? prev.good.combine(current.good) : current.good,
warning: prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning,
} as ColorSetConfig;
let combined = new ColorSetConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.dark = prev.dark !== undefined ? prev.dark.combine(current.dark) : current.dark;
combined.light = prev.light !== undefined ? prev.light.combine(current.light) : current.light;
combined.accent = prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent;
combined.attention = prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention;
combined.good = prev.good !== undefined ? prev.good.combine(current.good) : current.good;
combined.warning = prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning;
return combined;
}
return prev;
}, this);
@ -221,10 +221,10 @@ export class ThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
background: current.background !== undefined ? current.background : prev.background,
foreground: prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground,
} as ThemeConfig;
let combined = new ThemeConfig();
combined.background = current.background !== undefined ? current.background : prev.background;
combined.foreground = prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground;
return combined;
}
return prev;
}, this);
@ -248,10 +248,10 @@ export class ContainerConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
} as ContainerConfig;
let combined = new ContainerConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -265,7 +265,7 @@ export class ImageSizeConfig {
public medium: number;
public large: number;
constructor(json: any) {
constructor(json?: any) {
if (json) {
this.small = json['small'];
this.medium = json['medium'];
@ -277,11 +277,11 @@ export class ImageSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
} as ImageSizeConfig;
let combined = new ImageSizeConfig();
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
return combined;
}
return prev;
}, this);
@ -307,11 +307,11 @@ export class ShowCardActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
mode: current.mode !== undefined ? current.mode : prev.mode,
margin: current.margin !== undefined ? current.margin : prev.margin,
style: current.style !== undefined ? current.style : prev.style,
} as ShowCardActionConfig;
let combined = new ShowCardActionConfig();
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
combined.style = current.style !== undefined ? current.style : prev.style;
return combined;
}
return prev;
}, this);
@ -349,17 +349,17 @@ export class ActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
capacity: current.capacity !== undefined ? current.capacity : prev.capacity,
actionSetSpacing: current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing,
actionSpacing: current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing,
showCard: prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard,
cardExpanding: current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding,
direction: current.direction !== undefined ? current.direction : prev.direction,
align: current.align !== undefined ? current.align : prev.align,
iconPosition: current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition,
iconSize: current.iconSize !== undefined ? current.iconSize : prev.iconSize,
} as ActionConfig;
let combined = new ActionConfig();
combined.capacity = current.capacity !== undefined ? current.capacity : prev.capacity;
combined.actionSetSpacing = current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing;
combined.actionSpacing = current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing;
combined.showCard = prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard;
combined.cardExpanding = current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding;
combined.direction = current.direction !== undefined ? current.direction : prev.direction;
combined.align = current.align !== undefined ? current.align : prev.align;
combined.iconPosition = current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition;
combined.iconSize = current.iconSize !== undefined ? current.iconSize : prev.iconSize;
return combined;
}
return prev;
}, this);
@ -381,9 +381,9 @@ export class CardConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
allowCustomStyle: current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle,
} as CardConfig;
let combined = new CardConfig();
combined.allowCustomStyle = current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle;
return combined;
}
return prev;
}, this);
@ -407,10 +407,10 @@ export class ImageSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
imageSize: current.imageSize !== undefined ? current.imageSize : prev.imageSize,
maxImageHeight: current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight,
} as ImageSetConfig;
let combined = new ImageSetConfig();
combined.imageSize = current.imageSize !== undefined ? current.imageSize : prev.imageSize;
combined.maxImageHeight = current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight;
return combined;
}
return prev;
}, this);
@ -441,13 +441,13 @@ export class FactValueConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
} as FactValueConfig;
let combined = new FactValueConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
return combined;
}
return prev;
}, this);
@ -479,14 +479,14 @@ export class FactTitleConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
maxWidth: current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth,
} as FactTitleConfig;
let combined = new FactTitleConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
combined.maxWidth = current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth;
return combined;
}
return prev;
}, this);
@ -512,11 +512,11 @@ export class FactSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
title: prev.title !== undefined ? prev.title.combine(current.title) : current.title,
value: prev.value !== undefined ? prev.value.combine(current.value) : current.value,
margin: current.margin !== undefined ? current.margin : prev.margin,
} as FactSetConfig;
let combined = new FactSetConfig();
combined.title = prev.title !== undefined ? prev.title.combine(current.title) : current.title;
combined.value = prev.value !== undefined ? prev.value.combine(current.value) : current.value;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
return combined;
}
return prev;
}, this);
@ -548,15 +548,15 @@ export class InputThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
color: current.color !== undefined ? current.color : prev.color,
focusColor: current.focusColor !== undefined ? current.focusColor : prev.focusColor,
backgroundColor: current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor,
focusBackgroundColor:
current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor,
borderColor: current.borderColor !== undefined ? current.borderColor : prev.borderColor,
focusBorderColor: current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor,
} as InputThemeConfig;
let combined = new InputThemeConfig();
combined.color = current.color !== undefined ? current.color : prev.color;
combined.focusColor = current.focusColor !== undefined ? current.focusColor : prev.focusColor;
combined.backgroundColor = current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor;
combined.focusBackgroundColor =
current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor;
combined.borderColor = current.borderColor !== undefined ? current.borderColor : prev.borderColor;
combined.focusBorderColor = current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor;
return combined;
}
return prev;
}, this);
@ -580,10 +580,10 @@ export class InputConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
} as InputConfig;
let combined = new InputConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -607,10 +607,10 @@ export class MediaConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
defaultPosterUrl: current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl,
playButtonUrl: current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl,
} as MediaConfig;
let combined = new MediaConfig();
combined.defaultPosterUrl = current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl;
combined.playButtonUrl = current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl;
return combined;
}
return prev;
}, this);
@ -660,25 +660,26 @@ export class HostConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
spacing: prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing,
separator: prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator,
supportInteractive: current.supportInteractive !== undefined ? current.supportInteractive : prev.supportInteractive,
fontFamily: current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily,
fontSize: prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize,
fontWeight: prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight,
container: prev.container !== undefined ?
prev.container.combine(current.container) :
current.container,
imageSize: prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize,
action: prev.action !== undefined ? prev.action.combine(current.action) : current.action,
card: prev.card !== undefined ? prev.card.combine(current.card) : current.card,
imageSet: prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet,
factSet: prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet,
media: prev.media !== undefined ? prev.media.combine(current.media) : current.media,
input: prev.input !== undefined ? prev.input.combine(current.input) : current.input,
mode: current.mode !== undefined ? current.mode : prev.mode,
} as HostConfig;
let combined = new HostConfig();
combined.spacing = prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing;
combined.separator = prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator;
combined.supportInteractive = current.supportInteractive !== undefined ?
current.supportInteractive : prev.supportInteractive;
combined.fontFamily = current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily;
combined.fontSize = prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize;
combined.fontWeight = prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight;
combined.container = prev.container !== undefined ?
prev.container.combine(current.container) :
current.container;
combined.imageSize = prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize;
combined.action = prev.action !== undefined ? prev.action.combine(current.action) : current.action;
combined.card = prev.card !== undefined ? prev.card.combine(current.card) : current.card;
combined.imageSet = prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet;
combined.factSet = prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet;
combined.media = prev.media !== undefined ? prev.media.combine(current.media) : current.media;
combined.input = prev.input !== undefined ? prev.input.combine(current.input) : current.input;
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
return combined;
}
return prev;
}, this);

Просмотреть файл

@ -17,11 +17,12 @@ export class HostContext {
return this.sharedInstance;
}
public applyConfig(config: HostConfig) {
public applyConfig(config: any) {
const parsedConfig = ConfigManager.parseConfig(config);
if (this.config) {
this.config = this.config.combine(config);
this.config = this.config.combine(parsedConfig);
} else {
this.config = config;
this.config = parsedConfig;
}
}

Просмотреть файл

@ -3,7 +3,6 @@ import {
View,
} from 'react-native';
import { HostConfig } from '../Config/Types';
import { CardContext } from '../Contexts/CardContext';
import { HostContext } from '../Contexts/HostContext';
import { CardModel } from '../Models/Cards/Card';
@ -11,7 +10,7 @@ import { AdaptiveCardView } from './Cards/AdaptiveCard';
export interface IAdaptiveCardProps {
adaptiveCard: any;
config?: HostConfig;
config?: any;
style?: any;
onSubmit?: (data: any) => Promise<any>;
onOpenUrl?: (url: string) => Promise<any>;
@ -23,7 +22,7 @@ export interface IAdaptiveCardProps {
onWarning?: (warning: any) => void;
}
export class CardRootView extends React.PureComponent<IAdaptiveCardProps> {
export class CardRootView extends React.Component<IAdaptiveCardProps> {
public rootCardContext: CardContext;
// private styleConfig: StyleConfig;
@ -49,6 +48,17 @@ export class CardRootView extends React.PureComponent<IAdaptiveCardProps> {
this.rootCardContext.registerErrorHandler(this.props.onError);
this.rootCardContext.registerInfoHandler(this.props.onInfo);
this.rootCardContext.registerWarningHandler(this.props.onWarning);
}
public shouldComponentUpdate(nextProps: any) {
if (JSON.stringify(nextProps) !== JSON.stringify(this.props)) {
if (JSON.stringify(nextProps.config) !== JSON.stringify(this.props.config)) {
HostContext.getInstance().applyConfig(nextProps.config);
}
return true;
}
return false;
}
public render() {

Просмотреть файл

@ -13,14 +13,14 @@ export class SpacingConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
padding: current.padding !== undefined ? current.padding : prev.padding,
};
let combined = new SpacingConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
combined.padding = current.padding !== undefined ? current.padding : prev.padding;
return combined;
}
return prev;
}, this);
@ -40,11 +40,11 @@ export class SeparatorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
thickness: current.thickness !== undefined ? current.thickness : prev.thickness,
color: current.color !== undefined ? current.color : prev.color,
spacing: current.spacing !== undefined ? current.spacing : prev.spacing,
};
let combined = new SeparatorConfig();
combined.thickness = current.thickness !== undefined ? current.thickness : prev.thickness;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.spacing = current.spacing !== undefined ? current.spacing : prev.spacing;
return combined;
}
return prev;
}, this);
@ -66,13 +66,13 @@ export class FontSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
extraLarge: current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge,
};
let combined = new FontSizeConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
combined.extraLarge = current.extraLarge !== undefined ? current.extraLarge : prev.extraLarge;
return combined;
}
return prev;
}, this);
@ -92,11 +92,11 @@ export class FontWeightConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
lighter: current.lighter !== undefined ? current.lighter : prev.lighter,
bolder: current.bolder !== undefined ? current.bolder : prev.bolder,
};
let combined = new FontWeightConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.lighter = current.lighter !== undefined ? current.lighter : prev.lighter;
combined.bolder = current.bolder !== undefined ? current.bolder : prev.bolder;
return combined;
}
return prev;
}, this);
@ -115,10 +115,10 @@ export class ColorConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: current.default !== undefined ? current.default : prev.default,
subtle: current.subtle !== undefined ? current.subtle : prev.subtle,
};
let combined = new ColorConfig();
combined.default = current.default !== undefined ? current.default : prev.default;
combined.subtle = current.subtle !== undefined ? current.subtle : prev.subtle;
return combined;
}
return prev;
}, this);
@ -142,15 +142,15 @@ export class ColorSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
dark: prev.default !== undefined ? prev.dark.combine(current.dark) : current.dark,
light: prev.light !== undefined ? prev.light.combine(current.light) : current.light,
accent: prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent,
attention: prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention,
good: prev.good !== undefined ? prev.good.combine(current.good) : current.good,
warning: prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning,
};
let combined = new ColorSetConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.dark = prev.dark !== undefined ? prev.dark.combine(current.dark) : current.dark;
combined.light = prev.light !== undefined ? prev.light.combine(current.light) : current.light;
combined.accent = prev.accent !== undefined ? prev.accent.combine(current.accent) : current.accent;
combined.attention = prev.attention !== undefined ? prev.attention.combine(current.attention) : current.attention;
combined.good = prev.good !== undefined ? prev.good.combine(current.good) : current.good;
combined.warning = prev.warning !== undefined ? prev.warning.combine(current.warning) : current.warning;
return combined;
}
return prev;
}, this);
@ -169,10 +169,10 @@ export class ThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
background: current.background !== undefined ? current.background : prev.background,
foreground: prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground,
};
let combined = new ThemeConfig();
combined.background = current.background !== undefined ? current.background : prev.background;
combined.foreground = prev.foreground !== undefined ? prev.foreground.combine(current.foreground) : current.foreground;
return combined;
}
return prev;
}, this);
@ -191,10 +191,10 @@ export class ContainerConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new ContainerConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -214,11 +214,11 @@ export class ImageSizeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
small: current.small !== undefined ? current.small : prev.small,
medium: current.medium !== undefined ? current.medium : prev.medium,
large: current.large !== undefined ? current.large : prev.large,
};
let combined = new ImageSizeConfig();
combined.small = current.small !== undefined ? current.small : prev.small;
combined.medium = current.medium !== undefined ? current.medium : prev.medium;
combined.large = current.large !== undefined ? current.large : prev.large;
return combined;
}
return prev;
}, this);
@ -238,11 +238,11 @@ export class ShowCardActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
mode: current.mode !== undefined ? current.mode : prev.mode,
margin: current.margin !== undefined ? current.margin : prev.margin,
style: current.style !== undefined ? current.style : prev.style,
};
let combined = new ShowCardActionConfig();
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
combined.style = current.style !== undefined ? current.style : prev.style;
return combined;
}
return prev;
}, this);
@ -268,17 +268,17 @@ export class ActionConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
capacity: current.capacity !== undefined ? current.capacity : prev.capacity,
actionSetSpacing: current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing,
actionSpacing: current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing,
showCard: prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard,
cardExpanding: current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding,
direction: current.direction !== undefined ? current.direction : prev.direction,
align: current.align !== undefined ? current.align : prev.align,
iconPosition: current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition,
iconSize: current.iconSize !== undefined ? current.iconSize : prev.iconSize,
};
let combined = new ActionConfig();
combined.capacity = current.capacity !== undefined ? current.capacity : prev.capacity;
combined.actionSetSpacing = current.actionSetSpacing !== undefined ? current.actionSetSpacing : prev.actionSetSpacing;
combined.actionSpacing = current.actionSpacing !== undefined ? current.actionSpacing : prev.actionSpacing;
combined.showCard = prev.showCard !== undefined ? prev.showCard.combine(current.showCard) : current.showCard;
combined.cardExpanding = current.cardExpanding !== undefined ? current.cardExpanding : prev.cardExpanding;
combined.direction = current.direction !== undefined ? current.direction : prev.direction;
combined.align = current.align !== undefined ? current.align : prev.align;
combined.iconPosition = current.iconPosition !== undefined ? current.iconPosition : prev.iconPosition;
combined.iconSize = current.iconSize !== undefined ? current.iconSize : prev.iconSize;
return combined;
}
return prev;
}, this);
@ -296,9 +296,9 @@ export class CardConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
allowCustomStyle: current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle,
};
let combined = new CardConfig();
combined.allowCustomStyle = current.allowCustomStyle !== undefined ? current.allowCustomStyle : prev.allowCustomStyle;
return combined;
}
return prev;
}, this);
@ -317,10 +317,10 @@ export class ImageSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
imageSize: current.imageSize !== undefined ? current.imageSize : prev.imageSize,
maxImageHeight: current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight,
};
let combined = new ImageSetConfig();
combined.imageSize = current.imageSize !== undefined ? current.imageSize : prev.imageSize;
combined.maxImageHeight = current.maxImageHeight !== undefined ? current.maxImageHeight : prev.maxImageHeight;
return combined;
}
return prev;
}, this);
@ -343,13 +343,13 @@ export class FactValueConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
};
let combined = new FactValueConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
return combined;
}
return prev;
}, this);
@ -372,14 +372,14 @@ export class FactTitleConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
size: current.size !== undefined ? current.size : prev.size,
color: current.color !== undefined ? current.color : prev.color,
isSubtle: current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle,
weight: current.weight !== undefined ? current.weight : prev.weight,
wrap: current.wrap !== undefined ? current.wrap : prev.wrap,
maxWidth: current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth,
};
let combined = new FactTitleConfig();
combined.size = current.size !== undefined ? current.size : prev.size;
combined.color = current.color !== undefined ? current.color : prev.color;
combined.isSubtle = current.isSubtle !== undefined ? current.isSubtle : prev.isSubtle;
combined.weight = current.weight !== undefined ? current.weight : prev.weight;
combined.wrap = current.wrap !== undefined ? current.wrap : prev.wrap;
combined.maxWidth = current.maxWidth !== undefined ? current.maxWidth : prev.maxWidth;
return combined;
}
return prev;
}, this);
@ -399,11 +399,11 @@ export class FactSetConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
title: prev.title !== undefined ? prev.title.combine(current.title) : current.title,
value: prev.value !== undefined ? prev.value.combine(current.value) : current.value,
margin: current.margin !== undefined ? current.margin : prev.margin,
};
let combined = new FactSetConfig();
combined.title = prev.title !== undefined ? prev.title.combine(current.title) : current.title;
combined.value = prev.value !== undefined ? prev.value.combine(current.value) : current.value;
combined.margin = current.margin !== undefined ? current.margin : prev.margin;
return combined;
}
return prev;
}, this);
@ -426,14 +426,15 @@ export class InputThemeConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
color: current.color !== undefined ? current.color : prev.color,
focusColor: current.focusColor !== undefined ? current.focusColor : prev.focusColor,
backgroundColor: current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor,
focusBackgroundColor: current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor,
borderColor: current.borderColor !== undefined ? current.borderColor : prev.borderColor,
focusBorderColor: current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor,
};
let combined = new InputThemeConfig();
combined.color = current.color !== undefined ? current.color : prev.color;
combined.focusColor = current.focusColor !== undefined ? current.focusColor : prev.focusColor;
combined.backgroundColor = current.backgroundColor !== undefined ? current.backgroundColor : prev.backgroundColor;
combined.focusBackgroundColor =
current.focusBackgroundColor !== undefined ? current.focusBackgroundColor : prev.focusBackgroundColor;
combined.borderColor = current.borderColor !== undefined ? current.borderColor : prev.borderColor;
combined.focusBorderColor = current.focusBorderColor !== undefined ? current.focusBorderColor : prev.focusBorderColor;
return combined;
}
return prev;
}, this);
@ -452,10 +453,10 @@ export class InputConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
default: prev.default !== undefined ? prev.default.combine(current.default) : current.default,
emphasis: prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis,
};
let combined = new InputConfig();
combined.default = prev.default !== undefined ? prev.default.combine(current.default) : current.default;
combined.emphasis = prev.emphasis !== undefined ? prev.emphasis.combine(current.emphasis) : current.emphasis;
return combined;
}
return prev;
}, this);
@ -474,10 +475,10 @@ export class MediaConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
defaultPosterUrl: current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl,
playButtonUrl: current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl,
};
let combined = new MediaConfig();
combined.defaultPosterUrl = current.defaultPosterUrl !== undefined ? current.defaultPosterUrl : prev.defaultPosterUrl;
combined.playButtonUrl = current.playButtonUrl !== undefined ? current.playButtonUrl : prev.playButtonUrl;
return combined;
}
return prev;
}, this);
@ -509,25 +510,26 @@ export class HostConfig {
if (args) {
return args.reduce((prev, current) => {
if (current) {
return {
spacing: prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing,
separator: prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator,
supportInteractive: current.supportInteractive !== undefined ? current.supportInteractive : prev.supportInteractive,
fontFamily: current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily,
fontSize: prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize,
fontWeight: prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight,
container: prev.container !== undefined ?
prev.container.combine(current.container) :
current.container,
imageSize: prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize,
action: prev.action !== undefined ? prev.action.combine(current.action) : current.action,
card: prev.card !== undefined ? prev.card.combine(current.card) : current.card,
imageSet: prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet,
factSet: prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet,
media: prev.media !== undefined ? prev.media.combine(current.media) : current.media,
input: prev.input !== undefined ? prev.input.combine(current.input) : current.input,
mode: current.mode !== undefined ? current.mode : prev.mode,
};
let combined = new HostConfig();
combined.spacing = prev.spacing !== undefined ? prev.spacing.combine(current.spacing) : current.spacing;
combined.separator = prev.separator !== undefined ? prev.separator.combine(current.separator) : current.separator;
combined.supportInteractive = current.supportInteractive !== undefined ?
current.supportInteractive : prev.supportInteractive;
combined.fontFamily = current.fontFamily !== undefined ? current.fontFamily : prev.fontFamily;
combined.fontSize = prev.fontSize !== undefined ? prev.fontSize.combine(current.fontSize) : current.fontSize;
combined.fontWeight = prev.fontWeight !== undefined ? prev.fontWeight.combine(current.fontWeight) : current.fontWeight;
combined.container = prev.container !== undefined ?
prev.container.combine(current.container) :
current.container;
combined.imageSize = prev.imageSize !== undefined ? prev.imageSize.combine(current.imageSize) : current.imageSize;
combined.action = prev.action !== undefined ? prev.action.combine(current.action) : current.action;
combined.card = prev.card !== undefined ? prev.card.combine(current.card) : current.card;
combined.imageSet = prev.imageSet !== undefined ? prev.imageSet.combine(current.imageSet) : current.imageSet;
combined.factSet = prev.factSet !== undefined ? prev.factSet.combine(current.factSet) : current.factSet;
combined.media = prev.media !== undefined ? prev.media.combine(current.media) : current.media;
combined.input = prev.input !== undefined ? prev.input.combine(current.input) : current.input;
combined.mode = current.mode !== undefined ? current.mode : prev.mode;
return combined;
}
return prev;
}, this);

Просмотреть файл

@ -10,11 +10,12 @@ export class HostContext {
return this.sharedInstance;
}
applyConfig(config) {
const parsedConfig = ConfigManager.parseConfig(config);
if (this.config) {
this.config = this.config.combine(config);
this.config = this.config.combine(parsedConfig);
}
else {
this.config = config;
this.config = parsedConfig;
}
}
getConfig() {

Просмотреть файл

@ -4,7 +4,7 @@ import { CardContext } from '../Contexts/CardContext';
import { HostContext } from '../Contexts/HostContext';
import { CardModel } from '../Models/Cards/Card';
import { AdaptiveCardView } from './Cards/AdaptiveCard';
export class CardRootView extends React.PureComponent {
export class CardRootView extends React.Component {
constructor(props) {
super(props);
let hostContext = HostContext.getInstance();
@ -19,6 +19,15 @@ export class CardRootView extends React.PureComponent {
this.rootCardContext.registerInfoHandler(this.props.onInfo);
this.rootCardContext.registerWarningHandler(this.props.onWarning);
}
shouldComponentUpdate(nextProps) {
if (JSON.stringify(nextProps) !== JSON.stringify(this.props)) {
if (JSON.stringify(nextProps.config) !== JSON.stringify(this.props.config)) {
HostContext.getInstance().applyConfig(nextProps.config);
}
return true;
}
return false;
}
render() {
return (React.createElement(View, { style: { flex: 1 } },
React.createElement(AdaptiveCardView, { index: 0, model: new CardModel(this.props.adaptiveCard, undefined, this.rootCardContext), theme: 'default', style: this.props.style })));

Просмотреть файл

@ -11,8 +11,6 @@ class CardList extends React.Component {
render() {
const cards = this.props.cards.filter(item => item.selected).map(item => {return {...item, card: parseJson(item.card)}});
const config = parseJson(this.props.config);
console.log("=== Config: ", config);
console.log("=== Cards: ", cards);
return (
<div className="card-list">
<Scrollbars
@ -23,11 +21,11 @@ class CardList extends React.Component {
className="scrollbar"
{...this.props}>
<div className="card-list-inner">
{cards.map(card => <Card key={card.id} adaptiveCard={card.card}/>)}
{cards.map(card => <Card key={card.id} adaptiveCard={card.card} config={config}/>)}
</div>
</Scrollbars>
</div>
)
);
}
}

Просмотреть файл

@ -43,7 +43,9 @@ class Editor extends React.Component {
}
render() {
const code = this.props.mode === 'card' ? this.props.cards.find(x => x.id === this.props.cardId).card : this.props.config;
const code = this.props.mode === 'card' ?
(this.props.cardId ? this.props.cards.find(x => x.id === this.props.cardId).card : '')
: this.props.config;
const options = {
lineNumber: 'on',
selectOnLineNumbers: true,

Просмотреть файл

@ -6,6 +6,8 @@
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
z-index: 999;
/* swiping remove */
}
.sample label {
@ -68,6 +70,14 @@
visibility: hidden;
}
.remove-icon {
float: left;
line-height: 1;
background-color: transparent;
display: none;
}
.right-arrow-icon {
float: right;
line-height: 1;
@ -77,4 +87,8 @@
.active {
visibility: visible;
}
.show {
display: inline-block;
}

Просмотреть файл

@ -2,28 +2,53 @@ import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import RightArrowIcon from '../../static/icons/right-arrow.svg';
import RightArrowIcon from '../../static/icons/right-arrow.svg';
import RemoveIcon from '../../static/icons/remove.svg'
import './Sample.css';
class Sample extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleMouseOver = this.handleMouseOver.bind(this);
this.handleMouseOut = this.handleMouseOut.bind(this);
this.handleRemove = this.handleRemove.bind(this);
this.state = {
removable: false
}
}
handleChange(e) {
this.props.clickHandler(this.props.id, e.target.checked);
}
handleMouseOver() {
this.setState({
removable: true
})
}
handleMouseOut() {
this.setState({
removable: false
})
}
handleRemove() {
this.props.removeHandler(this.props.id);
}
render() {
const iconClassName = 'right-arrow-icon' + (this.props.mode === 'card' && this.props.cardId === this.props.id ? ' active' : '');
const rightArrowIconClass = 'right-arrow-icon' + (this.props.mode === 'card' && this.props.cardId === this.props.id ? ' active' : '');
const removeIconClass = 'remove-icon' + (this.state.removable ? ' show' : '');
return (
<div className="sample">
<input id={this.props.id} name="sample-name" type="checkbox" onChange={this.handleChange.bind(this)} checked={this.props.selected}/>
<label htmlFor={this.props.id}>{this.props.name}<RightArrowIcon className={iconClassName} /></label>
</div>
);
<div className="sample" onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
<input id={this.props.id} name="sample-name" type="checkbox" onChange={this.handleChange.bind(this)} checked={this.props.selected}/>
<label htmlFor={this.props.id}><RemoveIcon className={removeIconClass} onClick={this.handleRemove}/>{this.props.name}<RightArrowIcon className={rightArrowIconClass} /></label>
</div>
)
}
}
@ -33,7 +58,8 @@ Sample.propTypes = {
selected: PropTypes.bool.required,
mode: PropTypes.string.required,
cardId: PropTypes.string.required,
clickHandler: PropTypes.func.required
clickHandler: PropTypes.func.required,
removeHandler: PropTypes.func.required,
};
const mapStateToProps = (state) => {

Просмотреть файл

@ -12,6 +12,7 @@ class SampleList extends React.Component {
super(props);
this.handleClick = this.handleClick.bind(this);
this.handleAddEnter = this.handleAddEnter.bind(this);
this.handleRemove = this.handleRemove.bind(this);
}
handleClick(id, checked) {
@ -23,9 +24,12 @@ class SampleList extends React.Component {
this.props.modifyCard(id, this.props.cards.find(x => x.id === id).card);
}
handleRemove(id) {
this.props.removeCard(id);
}
handleAddEnter(e) {
if (e.key === 'Enter') {
console.log(e.target.value);
this.props.addCard(e.target.value);
e.target.value = '';
e.target.blur();
@ -47,7 +51,10 @@ class SampleList extends React.Component {
<input className="add-sample-input" placeholder="Add new card" onKeyPress={this.handleAddEnter}/>
</div>
<hr />
{this.props.cards.map((item) => <Sample key={item.id} id={item.id} name={item.name} selected={item.selected} clickHandler={this.handleClick}/>)}
{this.props.cards.map((item) => <Sample key={item.id} id={item.id} name={item.name} selected={item.selected}
clickHandler={this.handleClick}
removeHandler={this.handleRemove} />
)}
</div>
</Scrollbars>
</div>

Просмотреть файл

@ -26,7 +26,11 @@ export default function reducer(state={
case Constants.SET_CARD_SELECTED:
return {...state, cardId: action.id, cards: state.cards.map((item) => {return item.id === action.id ? {...item, selected: action.selected} : item})};
case Constants.REMOVE_CARD:
return {...state, cards: state.cards.filter((item) => item.id !== action.id)};
return {
...state,
cards: state.cards.filter((item) => item.id !== action.id),
cardId: action.id !== state.cardId ? state.cardId : ''
};
case Constants.ADD_CARD:
let newState = {...state, cards: state.cards.concat({name: action.name, card: '', selected: true, id: uuid()}), mode: 'card'};
newState.cardId = newState.cards[newState.cards.length-1].id;

Просмотреть файл

@ -1,7 +1,8 @@
{
"mode": "debug",
"choiceSetInputValueSeparator": ",",
"supportsInteractivity": true,
"fontFamily": "Segoe UI",
"fontFamily": "Roboto",
"spacing": {
"small": 3,
"default": 8,
@ -12,128 +13,147 @@
},
"separator": {
"lineThickness": 1,
"lineColor": "#EEEEEE"
"lineColor": "#00000015",
"spacing": 12
},
"fontSizes": {
"small": 120,
"default": 140,
"medium": 170,
"large": 210,
"extraLarge": 260
"small": 12,
"default": 14,
"medium": 17,
"large": 21,
"extraLarge": 26
},
"fontWeights": {
"lighter": 200,
"default": 400,
"bolder": 600
"bolder": 500
},
"imageSizes": {
"small": 40,
"medium": 80,
"large": 160
"small": 12,
"medium": 36,
"large": 64
},
"containerStyles": {
"default": {
"foregroundColors": {
"default": {
"default": "333333",
"subtle": "#EE333333"
"default": "#000000DE",
"subtle": "#0000008A"
},
"dark": {
"default": "#000000",
"subtle": "#66000000"
"subtle": "#00000066"
},
"light": {
"default": "#FFFFFF",
"subtle": "#33000000"
"subtle": "#FFFFFF33"
},
"accent": {
"default": "#2E89FC",
"subtle": "#882E89FC"
"default": "#006ae2",
"subtle": "#006ae2b2"
},
"good": {
"default": "#54a254",
"subtle": "#DD54a254"
"default": "#048e2e",
"subtle": "#048e2eb2"
},
"warning": {
"default": "#c3ab23",
"subtle": "#DDc3ab23"
"default": "#eb7b07",
"subtle": "#eb7b07b2"
},
"attention": {
"default": "#FF0000",
"subtle": "#DDFF0000"
"default": "#c80000",
"subtle": "#c80000b2"
}
},
"backgroundColor": "#EAEAEA"
"backgroundColor": "#FFFFFF00"
},
"emphasis": {
"foregroundColors": {
"default": {
"default": "#333333",
"subtle": "#EE333333"
"default": "#000000",
"subtle": "#00000066"
},
"dark": {
"default": "#000000",
"subtle": "#66000000"
"subtle": "#00000066"
},
"light": {
"default": "#FFFFFF",
"subtle": "#33000000"
"subtle": "#FFFFFF33"
},
"accent": {
"default": "#2E89FC",
"subtle": "#882E89FC"
"default": "#006ae2",
"subtle": "#006ae2b2"
},
"good": {
"default": "#54a254",
"subtle": "#DD54a254"
"default": "#048e2e",
"subtle": "#048e2eb2"
},
"warning": {
"default": "#c3ab23",
"subtle": "#DDc3ab23"
"default": "#eb7b07",
"subtle": "#eb7b07b2"
},
"attention": {
"default": "#FF0000",
"subtle": "#DDFF0000"
"default": "#c80000",
"subtle": "#c80000b2"
}
},
"backgroundColor": "#08000000"
"backgroundColor": "#FFFFFF00"
}
},
"actions": {
"maxActions": 5,
"spacing": "Default",
"buttonSpacing": 10,
"maxActions": 2,
"spacing": "large",
"buttonSpacing": 0,
"showCard": {
"actionMode": "Popup",
"actionMode": "inline",
"inlineTopMargin": 16,
"style": "emphasis"
},
"preExpandSingleShowCardAction": false,
"actionsOrientation": "Vertical",
"actionAlignment": "Stretch"
"actionsOrientation": "horizontal",
"actionAlignment": "left"
},
"adaptiveCard": {
"allowCustomStyle": false
},
"imageSet": {
"imageSize": "Medium",
"imageSize": "medium",
"maxImageHeight": 100
},
"factSet": {
"title": {
"size": "Default",
"color": "Default",
"size": "default",
"color": "default",
"isSubtle": false,
"weight": "Bolder",
"weight": "bolder",
"warp": true
},
"value": {
"size": "Default",
"color": "Default",
"size": "default",
"color": "default",
"isSubtle": false,
"weight": "Default",
"weight": "default",
"warp": true
},
"spacing": 5
"spacing": 10
},
"input": {
"default": {
"color": "#000000",
"focusColor": "#000000",
"backgroundColor": "#F3F3F3",
"focusBackgroundColor": "#FFFFFF",
"borderColor": "#F3F3F3",
"focusBorderColor": "#006ae2"
},
"emphasis": {
"color": "#000000",
"focusColor": "#000000",
"backgroundColor": "#FFFFFF",
"focusBackgroundColor": "#FFFFFF",
"borderColor": "#FFFFFF",
"focusBorderColor": "#006ae2"
}
}
}

Просмотреть файл

@ -0,0 +1 @@
<svg t="1536304274869" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3033" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M851.428571 755.428571q0 22.857143-16 38.857143l-77.714286 77.714286q-16 16-38.857143 16t-38.857143-16l-168-168-168 168q-16 16-38.857143 16t-38.857143-16l-77.714286-77.714286q-16-16-16-38.857143t16-38.857143l168-168-168-168q-16-16-16-38.857143t16-38.857143l77.714286-77.714286q16-16 38.857143-16t38.857143 16l168 168 168-168q16-16 38.857143-16t38.857143 16l77.714286 77.714286q16 16 16 38.857143t-16 38.857143l-168 168 168 168q16 16 16 38.857143z" p-id="3034" fill="#e16531"></path></svg>

После

Ширина:  |  Высота:  |  Размер: 737 B