Skip to content

Commit 1522e68

Browse files
author
Alex Terentiev
committed
fix package.json conflict
2 parents d73c3d3 + 41f2c7a commit 1522e68

18 files changed

+961
-526
lines changed

docs/documentation/docs/controls/AdaptiveCardHost.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ Three custom themes have been created for Microsoft Teams to emulate the colors
1111

1212
All Elements and Actions of Adaptive Cards have been redefined using Fluent UI React, both for SharePoint and Microsoft Teams (in this case the "Fluent UI Northstar" library is not used), adding and improving features that are not managed in Microsoft's implementation of the "adaptivecards-fluentui" library (Theme support for example).
1313

14+
Thanks to the "context" property that allows you to pass the SPFx context, whether the "data" property is passed or not, a new field called @context will be injected into the data object.
15+
16+
This allows, using Adaptive Cards templating syntax, to access to the context informations using the following fields (for more information on these fields, refer to the [BaseComponentContext](https://docs.microsoft.com/en-us/javascript/api/sp-component-base/basecomponentcontext) class):
17+
- "theme": property "theme" from the current theme applied to the card.
18+
- "aadInfo": Azure AD informations retrieved from the SPFx context object.
19+
- "cultureInfo": Culture informations retrieved from the SPFx context object.
20+
- "userInfo": User informations retrieved from the SPFx context object.
21+
- "spListInfo": Current List informations retrieved from the SPFx context object.
22+
- "spListItemInfo": Current List item informations retrieved from the SPFx context object.
23+
- "spSiteInfo": Current Site informations retrieved from the SPFx context object.
24+
- "spWebInfo": Current Web informations retrieved from the SPFx context object.
25+
1426
The Adaptive Cards version supported is 1.5, by using the 'adaptivecards' npm package version 2.10.0.
1527

1628
Here is an example of the control in action inside a Web Part:
@@ -27,22 +39,23 @@ Here is an example of the previous Web Part (using different Card), hosted as a
2739
- In your component file, import the `AdaptiveCardHost` control as follows:
2840

2941
```TypeScript
30-
import { AdaptiveCardHost, IAdaptiveCardHostActionResult, AdaptiveCardHostThemeType } from "@pnp/spfx-controls-react/lib/AdaptiveCardHost";
42+
import { AdaptiveCardHost, IAdaptiveCardHostActionResult, AdaptiveCardHostThemeType, Action, CardElement, CardObjectRegistry, HostCapabilities } from "@pnp/spfx-controls-react/lib/AdaptiveCardHost";
3143
```
3244

3345
- Example on use the `AdaptiveCardHost` control with only required properties:
3446

35-
```TSX
47+
```TypeScript
3648
<AdaptiveCardHost
3749
card={card}
3850
onInvokeAction={(action) => alert(JSON.stringify(action))}
3951
onError={(error) => alert(error.message)}
52+
context={this.props.context}
4053
/>
4154
```
4255

4356
- Example on use the `AdaptiveCardHost` control with all properties:
4457

45-
```TSX
58+
```TypeScript
4659
<AdaptiveCardHost
4760
card={card}
4861
data={data}
@@ -62,63 +75,68 @@ import { AdaptiveCardHost, IAdaptiveCardHostActionResult, AdaptiveCardHostThemeT
6275
onUpdateHostCapabilities={(hostCapabilities: HostCapabilities) => {
6376
hostCapabilities.setCustomProperty("CustomPropertyName", Date.now);
6477
}}
65-
isUniqueControlInPage={true}
78+
context={this.props.context}
6679
/>
6780
```
6881

6982
- Example on use the `AdaptiveCardHost` control with SharePoint Theme:
7083

71-
```TSX
84+
```TypeScript
7285
<AdaptiveCardHost
7386
card={card}
7487
themeType={AdaptiveCardHostThemeType.SharePoint}
7588
onInvokeAction={(action) => alert(JSON.stringify(action))}
7689
onError={(error) => alert(error.message)}
90+
context={this.props.context}
7791
/>
7892
```
7993

8094
- Example on use the `AdaptiveCardHost` control with SharePoint Theme "Section Variation" ('this.props.theme' is the theme that come from the Web Part) */):
8195

82-
```TSX
96+
```TypeScript
8397
<AdaptiveCardHost
8498
card={card}
8599
theme={this.props.theme}
86100
themeType={AdaptiveCardHostThemeType.SharePoint}
87101
onInvokeAction={(action) => alert(JSON.stringify(action))}
88102
onError={(error) => alert(error.message)}
103+
context={this.props.context}
89104
/>
90105
```
91106

92107
- Example on use the `AdaptiveCardHost` control with Teams "Default" Theme:
93108

94-
```TSX
109+
```TypeScript
95110
<AdaptiveCardHost
96111
card={card}
97112
themeType={AdaptiveCardHostThemeType.Teams}
98113
onInvokeAction={(action) => alert(JSON.stringify(action))}
99114
onError={(error) => alert(error.message)}
115+
context={this.props.context}
100116
/>
101117
```
102118

103119
- Example on use the `AdaptiveCardHost` control with Teams "Dark" Theme:
104120

105-
```TSX
121+
```TypeScript
106122
<AdaptiveCardHost
107123
card={card}
108124
themeType={AdaptiveCardHostThemeType.TeamsDark}
109125
onInvokeAction={(action) => alert(JSON.stringify(action))}
110126
onError={(error) => alert(error.message)}
127+
context={this.props.context}
111128
/>
112129
```
113130

114131
- Example on use the `AdaptiveCardHost` control with Teams "High Contrast" Theme:
115132

116-
```TSX
133+
```TypeScript
117134
<AdaptiveCardHost
118135
card={card}
119136
themeType={AdaptiveCardHostThemeType.TeamsHighContrast}
120137
onInvokeAction={(action) => alert(JSON.stringify(action))}
121138
onError={(error) => alert(error.message)}
139+
context={this.props.context}
122140
/>
123141
```
124142

@@ -132,15 +150,15 @@ The `AdaptiveCardHost` control can be configured with the following properties:
132150
| data | { "$root": object } | no | Set Data Source for template rendering. |
133151
| style | React.CSSProperties | no | Set CSS Style. |
134152
| className | string | no | Set CSS Class. |
135-
| theme | IPartialTheme or ITheme | no | Set Fluent UI Theme. Used only if the "themeType" property is set to 'ThemeType.SharePoint'. If not set or set to null or not defined, the theme passed through context will be searched, or the default theme of the page will be loaded. |
153+
| theme | IPartialTheme or ITheme | no | Set Fluent UI Theme. Used only if the "themeType" property is set to 'ThemeType.SharePoint'. If not set or set to null or not defined, the theme passed through context will be searched, or the default theme of the page will be loaded. However, the Theme object will be automatically injected into the data object, so that it can be used by the Adaptive Cards binding engine. |
136154
| themeType | ThemeType | no | Select the Type of Theme you want to use. If it is not set or set to null or undefined, the 'ThemeType.SharePoint' value will be used and the "theme" property or the theme passed through the context or default page will be loaded. In other cases, the chosen Microsoft Teams theme will be applied. |
137155
| hostConfig | object | no | Set custom HostConfig. |
138156
| onInvokeAction | (action: IAdaptiveCardActionResult) => void | yes | Invoked every time an Action is performed. |
139157
| onError | (error: Error) => void | yes | Invoked every time an exception occurs in the rendering phase. |
140158
| onSetCustomElements | (registry: CardObjectRegistry<CardElement>) => void | no | Invoked to manage Elements to the current Adaptive Card instance. |
141159
| onSetCustomActions | (registry: CardObjectRegistry<Action>) => void | no | Invoked to manage Actions to the current Adaptive Card instance. |
142160
| onUpdateHostCapabilities | (hostCapabilities: HostCapabilities) => void | no | Invoked to manage the HostCapabilities object like add custom properties. |
143-
| isUniqueControlInPage | boolean | no | Set to true if you want to use only one instance of this control per page, false for multiple controls. This affects how CSS variables are set. |
161+
| context | BaseComponentContext | no | Set the context from the SPFx component. If set, some context properties will be automatically injected into the data object, so they can be used by the Adaptive Cards binding engine. |
144162

145163
Interface `IAdaptiveCardHostActionResult`
146164

0 commit comments

Comments
 (0)