Skip to content

Commit 3cc5d98

Browse files
committed
bump to SPFx 1.19
1 parent 0bd23c1 commit 3cc5d98

File tree

10 files changed

+4567
-2399
lines changed

10 files changed

+4567
-2399
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ root = true
1010
# change these settings to your own preference
1111
indent_style = space
1212
indent_size = 2
13+
quote_type = single
1314

1415
# we recommend you to keep these unchanged
1516
end_of_line = lf

.yo-rc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"@microsoft/generator-sharepoint": {
3-
"version": "1.18.2",
3+
"version": "1.19.0",
44
"libraryName": "sp-dev-fx-controls-react",
55
"libraryId": "92b1e52c-a5fa-490a-bcf4-76080f39442c",
66
"environment": "spo",

package-lock.json

Lines changed: 4154 additions & 2126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,22 @@
3535
"@fluentui/styles": "0.66.5",
3636
"@fluentui/theme": "^2.6.6",
3737
"@iconify/react": "^4.1.1",
38-
"@microsoft/decorators": "1.18.2",
38+
"@microsoft/decorators": "1.19.0",
3939
"@microsoft/mgt-react": "3.1.3",
4040
"@microsoft/mgt-spfx": "3.1.3",
41-
"@microsoft/sp-adaptive-card-extension-base": "1.18.2",
42-
"@microsoft/sp-application-base": "1.18.2",
43-
"@microsoft/sp-component-base": "1.18.2",
44-
"@microsoft/sp-core-library": "1.18.2",
45-
"@microsoft/sp-dialog": "1.18.2",
46-
"@microsoft/sp-extension-base": "1.18.2",
47-
"@microsoft/sp-http": "1.18.2",
48-
"@microsoft/sp-listview-extensibility": "1.18.2",
49-
"@microsoft/sp-loader": "1.18.2",
50-
"@microsoft/sp-lodash-subset": "1.18.2",
51-
"@microsoft/sp-office-ui-fabric-core": "1.18.2",
52-
"@microsoft/sp-page-context": "1.18.2",
53-
"@microsoft/sp-property-pane": "1.18.2",
54-
"@microsoft/sp-webpart-base": "1.18.2",
41+
"@microsoft/sp-application-base": "1.19.0",
42+
"@microsoft/sp-component-base": "1.19.0",
43+
"@microsoft/sp-core-library": "1.19.0",
44+
"@microsoft/sp-dialog": "1.19.0",
45+
"@microsoft/sp-extension-base": "1.19.0",
46+
"@microsoft/sp-http": "1.19.0",
47+
"@microsoft/sp-listview-extensibility": "1.19.0",
48+
"@microsoft/sp-loader": "1.19.0",
49+
"@microsoft/sp-lodash-subset": "1.19.0",
50+
"@microsoft/sp-office-ui-fabric-core": "1.19.0",
51+
"@microsoft/sp-page-context": "1.19.0",
52+
"@microsoft/sp-property-pane": "1.19.0",
53+
"@microsoft/sp-webpart-base": "1.19.0",
5554
"@monaco-editor/loader": "^1.3.1",
5655
"@pnp/common": "2.5.0",
5756
"@pnp/odata": "2.5.0",
@@ -86,12 +85,12 @@
8685
"swiper": "^8.2.6"
8786
},
8887
"devDependencies": {
89-
"@microsoft/eslint-config-spfx": "1.18.2",
90-
"@microsoft/eslint-plugin-spfx": "1.18.2",
88+
"@microsoft/eslint-config-spfx": "1.20.1",
89+
"@microsoft/eslint-plugin-spfx": "1.20.1",
9190
"@microsoft/microsoft-graph-types": "^2.1.0",
9291
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
93-
"@microsoft/sp-build-web": "1.18.2",
94-
"@microsoft/sp-module-interfaces": "1.18.2",
92+
"@microsoft/sp-build-web": "1.20.1",
93+
"@microsoft/sp-module-interfaces": "1.20.1",
9594
"@rushstack/eslint-config": "2.5.1",
9695
"@types/chart.js": "2.7.40",
9796
"@types/enzyme": "^2.8.12",

src/controls/adaptiveCardHost/AdaptiveCardHost.tsx

Lines changed: 107 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1-
import { ThemeProvider } from '@fluentui/react-theme-provider';
2-
import { mergeThemes } from '@fluentui/theme/lib/mergeThemes';
3-
import { Action, AdaptiveCard, CardElement, CardObjectRegistry, ExecuteAction, GlobalRegistry, OpenUrlAction, SerializationContext, SubmitAction } from 'adaptivecards';
4-
import { Template } from 'adaptivecards-templating';
5-
import { IPartialTheme, ITheme } from '@fluentui/react/lib/Styling';
6-
import { CustomizerContext } from '@fluentui/react/lib/Utilities';
71
import * as React from 'react';
2+
import { useCallback, useEffect, useRef } from 'react';
3+
import { ThemeProvider } from '@fluentui/react-theme-provider';
4+
import { mergeThemes } from '@fluentui/theme';
85
import {
9-
useCallback,
10-
useEffect,
11-
useRef
12-
} from 'react';
6+
Action,
7+
AdaptiveCard,
8+
CardElement,
9+
CardObjectRegistry,
10+
ExecuteAction,
11+
GlobalRegistry,
12+
OpenUrlAction,
13+
SerializationContext,
14+
SubmitAction,
15+
} from 'adaptivecards';
16+
import { Template } from 'adaptivecards-templating';
17+
import { IPartialTheme, ITheme, CustomizerContext } from '@fluentui/react';
1318
import { fluentUIDefaultTheme } from '../../common/fluentUIThemes/FluentUIDefaultTheme';
1419
import { initializeAdaptiveCardHost } from './AdaptiveCardHost.HostConfig';
15-
import { initProcessMarkdown, injectContextProperty } from './AdaptiveCardHost.Utilities';
20+
import {
21+
initProcessMarkdown,
22+
injectContextProperty,
23+
} from './AdaptiveCardHost.Utilities';
1624
import { registerFluentUIActions, registerFluentUIElements } from './fluentUI';
1725
import { IAdaptiveCardHostProps } from './IAdaptiveCardHostProps';
1826
import { AdaptiveCardHostThemeType } from './models/AdaptiveCardHostThemeType';
1927
import { IAdaptiveCardHostActionResult } from './models/IAdaptiveCardHostActionResult';
2028

21-
export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element => {
29+
export const AdaptiveCardHost = (
30+
props: IAdaptiveCardHostProps
31+
): JSX.Element => {
2232
const renderElementRef = useRef<HTMLDivElement>(null);
2333
const adaptiveCardInstanceRef = useRef<AdaptiveCard>(null);
2434
const serializationContextInstanceRef = useRef<SerializationContext>(null);
2535
const fluentUIThemeInstanceRef = useRef<ITheme>(null);
2636
const fluentUICustomizerContext = React.useContext(CustomizerContext);
27-
const adaptiveCardInstanceRefDependencies = [props.card, props.onSetCustomElements, props.onSetCustomActions, props.onUpdateHostCapabilities];
37+
const adaptiveCardInstanceRefDependencies = [
38+
props.card,
39+
props.onSetCustomElements,
40+
props.onSetCustomActions,
41+
props.onUpdateHostCapabilities,
42+
];
2843

2944
// Init Process Markdown
3045
useEffect(() => {
@@ -40,31 +55,50 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
4055
// *****
4156

4257
// create executeAction
43-
const invokeAction = useCallback((action: Action) => {
44-
if (props.onInvokeAction) {
45-
let actionResult: IAdaptiveCardHostActionResult;
46-
const type = action.getJsonTypeName();
47-
switch (type) {
48-
case OpenUrlAction.JsonTypeName: {
49-
const openUrlAction = action as OpenUrlAction;
50-
actionResult = { type: type, title: openUrlAction.title, url: openUrlAction.url };
51-
}
52-
break;
53-
case SubmitAction.JsonTypeName: {
54-
const submitAction = action as SubmitAction;
55-
actionResult = { type: type, title: submitAction.title, data: submitAction.data };
58+
const invokeAction = useCallback(
59+
(action: Action) => {
60+
if (props.onInvokeAction) {
61+
let actionResult: IAdaptiveCardHostActionResult;
62+
const type = action.getJsonTypeName();
63+
switch (type) {
64+
case OpenUrlAction.JsonTypeName:
65+
{
66+
const openUrlAction = action as OpenUrlAction;
67+
actionResult = {
68+
type: type,
69+
title: openUrlAction.title,
70+
url: openUrlAction.url,
71+
};
72+
}
73+
break;
74+
case SubmitAction.JsonTypeName:
75+
{
76+
const submitAction = action as SubmitAction;
77+
actionResult = {
78+
type: type,
79+
title: submitAction.title,
80+
data: submitAction.data,
81+
};
82+
}
83+
break;
84+
case ExecuteAction.JsonTypeName:
85+
{
86+
const executeAction = action as ExecuteAction;
87+
actionResult = {
88+
type: type,
89+
title: executeAction.title,
90+
data: executeAction.data,
91+
verb: executeAction.verb,
92+
};
93+
}
94+
break;
5695
}
57-
break;
58-
case ExecuteAction.JsonTypeName: {
59-
const executeAction = action as ExecuteAction;
60-
actionResult = { type: type, title: executeAction.title, data: executeAction.data, verb: executeAction.verb };
61-
}
62-
break;
63-
}
6496

65-
props.onInvokeAction(actionResult);
66-
}
67-
}, [props.onInvokeAction]);
97+
props.onInvokeAction(actionResult);
98+
}
99+
},
100+
[props.onInvokeAction]
101+
);
68102
// *****
69103

70104
// set hostConfig
@@ -78,7 +112,8 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
78112
}
79113

80114
// if this control is wrapped on "ThemeProvider" take the theme from the context
81-
const contextTheme: ITheme | IPartialTheme = fluentUICustomizerContext.customizations.settings.theme;
115+
const contextTheme: ITheme | IPartialTheme =
116+
fluentUICustomizerContext.customizations.settings.theme;
82117
// *****
83118

84119
if (props.theme) {
@@ -90,18 +125,25 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
90125
}
91126
// **********
92127

93-
const hostConfigResult = initializeAdaptiveCardHost(inputThemeType, mergeThemes(fluentUIDefaultTheme(), inputFluentUITheme));
128+
const hostConfigResult = initializeAdaptiveCardHost(
129+
inputThemeType,
130+
mergeThemes(fluentUIDefaultTheme(), inputFluentUITheme)
131+
);
94132
const currentHostConfig = hostConfigResult.hostConfig;
95133

96134
fluentUIThemeInstanceRef.current = hostConfigResult.theme;
97135
adaptiveCardInstanceRef.current.hostConfig = hostConfigResult.hostConfig;
98136

99-
100137
if (props.onUpdateHostCapabilities) {
101138
props.onUpdateHostCapabilities(currentHostConfig.hostCapabilities);
102139
}
103-
104-
}, [...adaptiveCardInstanceRefDependencies, fluentUICustomizerContext, props.theme, props.themeType, props.hostConfig]);
140+
}, [
141+
...adaptiveCardInstanceRefDependencies,
142+
fluentUICustomizerContext,
143+
props.theme,
144+
props.themeType,
145+
props.hostConfig,
146+
]);
105147
// *****
106148

107149
// set invokeAction
@@ -132,7 +174,6 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
132174
const currentSerializationContext = serializationContextInstanceRef.current;
133175
currentSerializationContext.setElementRegistry(elementRegistry);
134176
currentSerializationContext.setActionRegistry(actionRegistry);
135-
136177
}, [...adaptiveCardInstanceRefDependencies]);
137178
// *****
138179

@@ -147,30 +188,48 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
147188
const currentAdaptiveCard = adaptiveCardInstanceRef.current;
148189
try {
149190
const template = new Template(props.card);
150-
const evaluationContext = injectContextProperty(props.data, fluentUIThemeInstanceRef.current, props.context);
191+
const evaluationContext = injectContextProperty(
192+
props.data,
193+
fluentUIThemeInstanceRef.current,
194+
props.context
195+
);
151196
const cardPayload = template.expand(evaluationContext);
152197

153-
currentAdaptiveCard.parse(cardPayload, serializationContextInstanceRef.current);
198+
currentAdaptiveCard.parse(
199+
cardPayload,
200+
serializationContextInstanceRef.current
201+
);
154202

155203
const renderedElement = currentAdaptiveCard.render();
156204
// If this isn't acceptable, we should compare the old template with the new template
157205
if (renderedElement.outerHTML !== currentRenderElement.innerHTML) {
158-
currentRenderElement.innerHTML = "";
206+
currentRenderElement.innerHTML = '';
159207
currentRenderElement.appendChild(renderedElement);
160208
}
161209
} catch (cardRenderError) {
162210
if (props.onError) {
163211
props.onError(cardRenderError);
164212
}
165213
}
166-
}, [...adaptiveCardInstanceRefDependencies, props.data, props.hostConfig, props.onError]);
214+
}, [
215+
...adaptiveCardInstanceRefDependencies,
216+
props.data,
217+
props.hostConfig,
218+
props.onError,
219+
]);
167220
// *****
168221

169222
return (
170-
<ThemeProvider theme={(fluentUIThemeInstanceRef.current) ? fluentUIThemeInstanceRef.current : fluentUIDefaultTheme()}>
223+
<ThemeProvider
224+
theme={
225+
fluentUIThemeInstanceRef.current
226+
? fluentUIThemeInstanceRef.current
227+
: fluentUIDefaultTheme()
228+
}
229+
>
171230
<div
172231
ref={renderElementRef}
173-
className={`${(props.className) ? props.className : ""}`}
232+
className={`${props.className ? props.className : ''}`}
174233
style={props.style}
175234
/>
176235
</ThemeProvider>

src/controls/adaptiveCardHost/fluentUI/HostConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { LocalizedFontFamilies } from '@fluentui/theme/lib/fonts';
1+
import { LocalizedFontFamilies } from '@fluentui/theme';
22
import { ActionAlignment, HostConfig, TextColor, TextWeight } from 'adaptivecards';
3-
import { ITheme } from '@fluentui/react/lib/Styling';
3+
import type { ITheme } from '@fluentui/react';
44

55
const lightenDarkenColor = (col: string, amt: number): string => {
66
let usePound = false;

src/controls/adaptiveCardHost/fluentUI/Styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LocalizedFontFamilies } from '@fluentui/theme/lib/fonts';
1+
import { LocalizedFontFamilies } from '@fluentui/theme';
22
import { IReadonlyTheme } from '@microsoft/sp-component-base';
33
import { create } from 'nano-css';
44

0 commit comments

Comments
 (0)