@microsoft/generator-sharepoint 1.13.0-beta.19 → 1.13.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/lib/common/BaseGenerator.d.ts +14 -15
  2. package/lib/common/BaseGenerator.d.ts.map +1 -1
  3. package/lib/common/BaseGenerator.js +17 -21
  4. package/lib/common/ConfigJsonManager.d.ts +4 -4
  5. package/lib/common/ConfigJsonManager.d.ts.map +1 -1
  6. package/lib/common/ConfigJsonManager.js +3 -2
  7. package/lib/common/JsonManager.d.ts +3 -3
  8. package/lib/common/JsonManager.d.ts.map +1 -1
  9. package/lib/common/PackageJsonManager.d.ts +2 -2
  10. package/lib/common/PackageJsonManager.d.ts.map +1 -1
  11. package/lib/common/PackageJsonManager.js +0 -1
  12. package/lib/common/PackageSolutionJsonManager.d.ts +4 -4
  13. package/lib/common/PackageSolutionJsonManager.d.ts.map +1 -1
  14. package/lib/common/PackageSolutionJsonManager.js +2 -1
  15. package/lib/common/ServeJsonManager.d.ts +3 -3
  16. package/lib/common/ServeJsonManager.d.ts.map +1 -1
  17. package/lib/common/TeamsManifestJsonManager.d.ts +3 -3
  18. package/lib/common/TeamsManifestJsonManager.d.ts.map +1 -1
  19. package/lib/common/YeomanConfiguration.d.ts +1 -1
  20. package/lib/common/YeomanConfiguration.d.ts.map +1 -1
  21. package/lib/common/dependency/adaptiveCardExtension/firstParty.json +7 -7
  22. package/lib/common/dependency/adaptiveCardExtension/firstPartyPlusBeta.json +7 -7
  23. package/lib/common/dependency/applicationCustomizer.json +2 -2
  24. package/lib/common/dependency/applicationCustomizerPlusBeta.json +2 -2
  25. package/lib/common/dependency/commandSet.json +2 -2
  26. package/lib/common/dependency/commandSetPlusBeta.json +2 -2
  27. package/lib/common/dependency/extension/firstParty.json +6 -6
  28. package/lib/common/dependency/extension/firstPartyPlusBeta.json +6 -6
  29. package/lib/common/dependency/fieldCustomizer.json +1 -1
  30. package/lib/common/dependency/fieldCustomizerPlusBeta.json +1 -1
  31. package/lib/common/dependency/library/firstParty.json +4 -4
  32. package/lib/common/dependency/library/firstPartyPlusBeta.json +4 -4
  33. package/lib/common/dependency/react.json +4 -4
  34. package/lib/common/dependency/searchQueryModifier.json +1 -1
  35. package/lib/common/dependency/searchQueryModifierPlusBeta.json +1 -1
  36. package/lib/common/dependency/webpart/firstParty.json +9 -9
  37. package/lib/common/dependency/webpart/firstPartyPlusBeta.json +9 -9
  38. package/lib/generators/adaptiveCardExtension/index.d.ts +7 -3
  39. package/lib/generators/adaptiveCardExtension/index.d.ts.map +1 -1
  40. package/lib/generators/adaptiveCardExtension/index.js +19 -12
  41. package/lib/generators/adaptiveCardExtension/templates/imageCardView/CardView.ts +21 -2
  42. package/lib/generators/adaptiveCardExtension/templates/{base → manifestTemplate/baseTemplate}/{componentClassName}.manifest.json +1 -1
  43. package/lib/generators/adaptiveCardExtension/templates/manifestTemplate/imageTemplate/{componentClassName}.manifest.json +30 -0
  44. package/lib/generators/app/index.d.ts +1 -1
  45. package/lib/generators/app/index.d.ts.map +1 -1
  46. package/lib/generators/app/index.js +7 -2
  47. package/lib/generators/applicationCustomizer/index.d.ts +3 -3
  48. package/lib/generators/applicationCustomizer/index.d.ts.map +1 -1
  49. package/lib/generators/applicationCustomizer/index.js +0 -3
  50. package/lib/generators/commandSet/index.d.ts +3 -3
  51. package/lib/generators/commandSet/index.d.ts.map +1 -1
  52. package/lib/generators/commandSet/index.js +0 -3
  53. package/lib/generators/component/BaseComponentGenerator.d.ts +1 -1
  54. package/lib/generators/component/BaseComponentGenerator.d.ts.map +1 -1
  55. package/lib/generators/component/BaseComponentGenerator.js +0 -2
  56. package/lib/generators/component/index.d.ts +4 -3
  57. package/lib/generators/component/index.d.ts.map +1 -1
  58. package/lib/generators/component/index.js +4 -8
  59. package/lib/generators/extension/BaseExtensionGenerator.d.ts +3 -3
  60. package/lib/generators/extension/BaseExtensionGenerator.d.ts.map +1 -1
  61. package/lib/generators/extension/BaseExtensionGenerator.js +0 -1
  62. package/lib/generators/extension/index.d.ts +3 -3
  63. package/lib/generators/extension/index.d.ts.map +1 -1
  64. package/lib/generators/extension/index.js +0 -3
  65. package/lib/generators/fieldCustomizer/index.d.ts +3 -3
  66. package/lib/generators/fieldCustomizer/index.d.ts.map +1 -1
  67. package/lib/generators/fieldCustomizer/index.js +0 -3
  68. package/lib/generators/fieldCustomizer/templates/none/{componentClassName}.module.scss +4 -4
  69. package/lib/generators/fieldCustomizer/templates/react/components/{componentName}.module.scss +4 -4
  70. package/lib/generators/library/index.d.ts +3 -3
  71. package/lib/generators/library/index.d.ts.map +1 -1
  72. package/lib/generators/library/index.js +1 -4
  73. package/lib/generators/searchQueryModifier/index.d.ts +3 -3
  74. package/lib/generators/searchQueryModifier/index.d.ts.map +1 -1
  75. package/lib/generators/searchQueryModifier/index.js +0 -3
  76. package/lib/generators/solution/index.d.ts +2 -2
  77. package/lib/generators/solution/index.d.ts.map +1 -1
  78. package/lib/generators/solution/index.js +26 -51
  79. package/lib/generators/solution/templates/base/README.md +1 -1
  80. package/lib/generators/solution/templates/base/tslint.json +0 -1
  81. package/lib/generators/solution/templates/spo/tsconfig.json +1 -1
  82. package/lib/generators/webpart/index.d.ts +3 -3
  83. package/lib/generators/webpart/index.d.ts.map +1 -1
  84. package/lib/generators/webpart/index.js +0 -3
  85. package/lib/generators/webpart/templates/base/loc/en-us.js +1 -5
  86. package/lib/generators/webpart/templates/base/loc/mystrings.d.ts +0 -4
  87. package/lib/generators/webpart/templates/images/color.png +0 -0
  88. package/lib/generators/webpart/templates/images/outline.png +0 -0
  89. package/lib/generators/webpart/templates/none/{componentClassName}.module.scss +47 -40
  90. package/lib/generators/webpart/templates/none/{componentClassName}.ts +12 -170
  91. package/lib/generators/webpart/templates/react/components/I{componentName}Props.ts +0 -4
  92. package/lib/generators/webpart/templates/react/components/{componentName}.module.scss +47 -40
  93. package/lib/generators/webpart/templates/react/components/{componentName}.tsx +8 -38
  94. package/lib/generators/webpart/templates/react/{componentClassName}.ts +1 -138
  95. package/package.json +4 -4
  96. package/lib/generators/solution/templates/base/config/copy-assets.json +0 -4
  97. package/lib/generators/webpart/templates/base/assets/welcome-dark.png +0 -0
  98. package/lib/generators/webpart/templates/base/assets/welcome-light.png +0 -0
@@ -4,12 +4,6 @@ import {
4
4
  PropertyPaneTextField
5
5
  } from '@microsoft/sp-property-pane';
6
6
  import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
7
- import {
8
- ThemeProvider,
9
- ThemeChangedEventArgs,
10
- IReadonlyTheme,
11
- ITheme
12
- } from '@microsoft/sp-component-base';
13
7
  import { escape } from '@microsoft/sp-lodash-subset';
14
8
 
15
9
  import styles from './<%= componentClassName %>.module.scss';
@@ -21,174 +15,22 @@ export interface I<%= componentClassName %>Props {
21
15
 
22
16
  export default class <%= componentClassName %> extends BaseClientSideWebPart<I<%= componentClassName %>Props> {
23
17
 
24
- private _themeProvider: ThemeProvider;
25
- private _themeVariant: IReadonlyTheme | undefined;
26
- private _isDarkTheme: boolean = false;
27
- private _environmentMessage: string = '';
28
- private _hasTeamsContext: boolean = false;
29
-
30
- protected onInit(): Promise<void> {
31
- this._hasTeamsContext = !!this.context.sdks.microsoftTeams;
32
-
33
- if (this._hasTeamsContext) {
34
- // handling MS Teams theme
35
- const teamsTheme = this.context.sdks.microsoftTeams.context.theme;
36
- this._updateTheme(teamsTheme);
37
-
38
- this.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler(this._handleTeamsThemeChangedEvent);
39
- }
40
- else {
41
- // Consume the new ThemeProvider service
42
- this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
43
-
44
- // If it exists, get the theme variant
45
- this._themeVariant = this._themeProvider.tryGetTheme();
46
- this._updateTheme(this._themeVariant);
47
-
48
- // Register a handler to be notified if the theme variant changes
49
- this._themeProvider.themeChangedEvent.add(this, this._handleSPThemeChangedEvent);
50
- }
51
-
52
- this._environmentMessage = this._getEnvironmentMessage();
53
-
54
- return super.onInit();
55
- }
56
-
57
18
  public render(): void {
58
19
  this.domElement.innerHTML = `
59
- <div class="${ styles.<%= componentNameCamelCase %> } ${ this._hasTeamsContext ? styles.teams : '' }">
60
- <div class="${ styles.container }">
61
- <div class="${ styles.row }">
62
- <div class="${ styles.column } ${ styles.center }">
63
- <img src="${this._isDarkTheme ? require('./assets/welcome-dark.png') : require('./assets/welcome-light.png')}" class="${styles.welcomeImage}" />
64
- </div>
65
- </div>
66
- <div class="${ styles.row }">
67
- <div class="${ styles.column } ${ styles.center }">
68
- <span class="${ styles.title }">Well done, ${this.context.pageContext.user.displayName}!</span>
69
- <p class="${ styles.subTitle }">${this._environmentMessage}</p>
70
- <p class="${ styles.subTitle }">Web part property value: <span class="${ styles.description }"> ${escape(this.properties.description)}</span></p>
20
+ <div class="${ styles.<%= componentNameCamelCase %> }">
21
+ <div class="${ styles.container }">
22
+ <div class="${ styles.row }">
23
+ <div class="${ styles.column }">
24
+ <span class="${ styles.title }">Welcome to SharePoint!</span>
25
+ <p class="${ styles.subTitle }">Customize SharePoint experiences using Web Parts.</p>
26
+ <p class="${ styles.description }">${escape(this.properties.description)}</p>
27
+ <a href="https://aka.ms/spfx" class="${ styles.button }">
28
+ <span class="${ styles.label }">Learn more</span>
29
+ </a>
30
+ </div>
71
31
  </div>
72
32
  </div>
73
- <div class="${ styles.row }">
74
- <div class="${ styles.column }">
75
- <span class="${ styles.header }">Welcome to SharePoint Framework!</span>
76
- <p class="${ styles.content }">
77
- The SharePoint Framework (SPFx) is a extensibility model for Microsoft Viva, Microsoft Teams and SharePoint. It's the easiest way to extend Microsoft 365 with automatic Single Sign On, automatic hosting and industry standard tooling.
78
- </p>
79
- <span class="${ styles.subheader }">Learn more about SPFx development:</span>
80
- <p class="${ styles.content }">
81
- <ul>
82
- <li><a class="${styles.link}" href="https://aka.ms/spfx" target="_blank">Overview of the SharePoint Framework</a></li>
83
- <li><a class="${styles.link}" href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/notes-on-solution-packaging" target="_blank">SharePoint solution packaging</a></li>
84
- <li><a class="${styles.link}" href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview" target="_blank">Build for Microsoft Teams using SharePoint Framework</a></li>
85
- <li><a class="${styles.link}" href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/use-fabric-react-components" target="_blank">Use Fluent UI components in your SharePoint client-side web part</a></li>
86
- <li><a class="${styles.link}" href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis" target="_blank">Use Microsoft Graph in your solution</a></li>
87
- <li><a class="${styles.link}" href="https://docs.microsoft.com/en-us/javascript/api/overview/sharepoint?view=sp-typescript-latest" target="_blank">SharePoint Framework API reference</a></li>
88
- <li><a class="${styles.link}" href="https://aka.ms/m365pnp" target="_blank">Microsoft 365 Community Assets - Calls, samples and documentation</a></li>
89
- <li><a class="${styles.link}" href="https://aka.ms/m365/devprogram" target="_blank">Register to Microsoft 365 Developer program for a free developer tenant</a></li>
90
- </ul>
91
- </p>
92
- </div>
93
- </div>
94
- </div>
95
- </div>`;
96
- }
97
-
98
- /**
99
- * Update the current theme variant reference and re-render.
100
- *
101
- * @param args The new theme
102
- */
103
- private _handleSPThemeChangedEvent = (args: ThemeChangedEventArgs): void => {
104
- this._themeVariant = args.theme;
105
- this._updateTheme(this._themeVariant);
106
- this.render();
107
- }
108
-
109
- /**
110
- * Handle Teams theme change callback.
111
- *
112
- * @param args The new theme
113
- */
114
- private _handleTeamsThemeChangedEvent = (theme: string): void => {
115
- this._updateTheme(theme);
116
- this.render();
117
- }
118
-
119
- /**
120
- * Updates fields based on the new theme
121
- * @param currentTheme updated theme
122
- */
123
- private _updateTheme = (currentTheme: IReadonlyTheme | string) => {
124
- this._setIsDarkTheme(currentTheme);
125
- this._setCSSVariables();
126
- }
127
-
128
- /**
129
- * Updates the _isDarkTheme based on current SharePoint or Teams theme
130
- */
131
- private _setIsDarkTheme = (currentTheme: IReadonlyTheme | string) => {
132
- if (typeof currentTheme === 'string') { // Teams theme
133
- this._isDarkTheme = currentTheme !== 'default'; // contrast theme is interpreted as dark
134
- }
135
- else { // SharePoint theme
136
- const theme = currentTheme as ITheme;
137
- this._isDarkTheme = !!theme && !!theme.isInverted;
138
- }
139
- }
140
-
141
- private _setCSSVariables = () => {
142
- let primaryText = '#323130'; // default
143
- let linkText = '#03787c';
144
- if (this._themeVariant) {
145
- const {
146
- semanticColors
147
- } = this._themeVariant;
148
- primaryText = semanticColors.bodyText;
149
- linkText = semanticColors.link;
150
- }
151
- else if (this._hasTeamsContext) { // fallback for Teams
152
- primaryText = this._isDarkTheme ? '#FFFFFF' : '#242424';
153
- linkText = this._isDarkTheme ? '#FFFFFF' : '#494B83';
154
- }
155
- else { // fallback for single app page
156
- primaryText = this._isDarkTheme ? '#3a96dd' : '#323130';
157
- linkText = this._isDarkTheme ? '#3a96dd' : '#03787c';
158
- }
159
-
160
- this.domElement.style.setProperty('--primaryText', primaryText);
161
- this.domElement.style.setProperty('--linkText', linkText);
162
- }
163
-
164
- private _getEnvironmentMessage = (): string => {
165
- // checking for local environment
166
- let isLocal: boolean = false;
167
- const {
168
- loaderConfig
169
- } = this.manifest;
170
-
171
- if (loaderConfig && loaderConfig.internalModuleBaseUrls && loaderConfig.internalModuleBaseUrls.length) {
172
- isLocal = /^http(s)?\:\/\/localhost/gmi.test(loaderConfig.internalModuleBaseUrls[0]);
173
- }
174
-
175
- if (this._hasTeamsContext) { // running in Teams
176
- return isLocal ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
177
- }
178
-
179
- return isLocal ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment;
180
- }
181
-
182
- protected onDispose(): void {
183
- //
184
- // unregistering theme changed handlers
185
- //
186
- if (this._hasTeamsContext) {
187
- this.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler(null);
188
- }
189
- else {
190
- this._themeProvider.themeChangedEvent.remove(this, this._handleSPThemeChangedEvent);
191
- }
33
+ </div>`;
192
34
  }
193
35
 
194
36
  protected get dataVersion(): Version {
@@ -1,7 +1,3 @@
1
1
  export interface I<%= componentName %>Props {
2
2
  description: string;
3
- isDarkTheme: boolean;
4
- environmentMessage: string;
5
- hasTeamsContext: boolean;
6
- userDisplayName: string;
7
3
  }
@@ -1,67 +1,74 @@
1
1
  @import '~office-ui-fabric-react/dist/sass/References.scss';
2
2
 
3
3
  .<%= componentNameCamelCase %> {
4
- &.teams {
5
- font-family: $ms-font-family-fallbacks;
6
- }
7
-
8
4
  .container {
9
- @include ms-Grid;
10
- color: var(--primaryText, #323130); // note: CSS variables support is limited to modern browsers only
5
+ max-width: 700px;
6
+ margin: 0px auto;
7
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
11
8
  }
12
9
 
13
10
  .row {
14
11
  @include ms-Grid-row;
15
- padding-top: 0.5rem;
12
+ @include ms-fontColor-white;
13
+ background-color: $ms-color-themeDark;
14
+ padding: 20px;
16
15
  }
17
16
 
18
17
  .column {
19
18
  @include ms-Grid-col;
20
- @include ms-sm12;
21
- @include ms-md8;
22
- @include ms-mdOffset2;
23
- @include ms-lg8;
24
- @include ms-lgOffset2;
25
- }
26
-
27
- .welcomeImage {
28
- width: 100%;
29
- max-width: 420px;
30
- }
31
-
32
- .center {
33
- text-align: center;
19
+ @include ms-lg10;
20
+ @include ms-xl8;
21
+ @include ms-xlPush2;
22
+ @include ms-lgPush1;
34
23
  }
35
24
 
36
25
  .title {
37
- @include ms-fontSize-18;
38
- @include ms-fontWeight-semibold;
26
+ @include ms-font-xl;
27
+ @include ms-fontColor-white;
39
28
  }
40
29
 
41
30
  .subTitle {
42
- @include ms-fontSize-14;
31
+ @include ms-font-l;
32
+ @include ms-fontColor-white;
43
33
  }
44
34
 
45
- .header {
46
- @include ms-fontSize-18;
47
- @include ms-fontWeight-semibold;
35
+ .description {
36
+ @include ms-font-l;
37
+ @include ms-fontColor-white;
48
38
  }
49
39
 
50
- .subheader {
51
- @include ms-fontSize-14;
52
- @include ms-fontWeight-semibold;
53
- }
40
+ .button {
41
+ // Our button
42
+ text-decoration: none;
43
+ height: 32px;
54
44
 
55
- .content {
56
- @include ms-fontSize-14;
57
- }
45
+ // Primary Button
46
+ min-width: 80px;
47
+ background-color: $ms-color-themePrimary;
48
+ border-color: $ms-color-themePrimary;
49
+ color: $ms-color-white;
58
50
 
59
- .link {
60
- color: var(--linkText, #03787c); // note: CSS variables support is limited to modern browsers only
61
- }
51
+ // Basic Button
52
+ outline: transparent;
53
+ position: relative;
54
+ font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
55
+ -webkit-font-smoothing: antialiased;
56
+ font-size: $ms-font-size-m;
57
+ font-weight: $ms-font-weight-regular;
58
+ border-width: 0;
59
+ text-align: center;
60
+ cursor: pointer;
61
+ display: inline-block;
62
+ padding: 0 16px;
62
63
 
63
- .description {
64
- @include ms-fontWeight-bold;
65
- @include ms-fontSize-14;
64
+ .label {
65
+ font-weight: $ms-font-weight-semibold;
66
+ font-size: $ms-font-size-m;
67
+ height: 32px;
68
+ line-height: 32px;
69
+ margin: 0 4px;
70
+ vertical-align: top;
71
+ display: inline-block;
72
+ }
66
73
  }
67
74
  }
@@ -5,49 +5,19 @@ import { escape } from '@microsoft/sp-lodash-subset';
5
5
 
6
6
  export default class <%= componentName %> extends React.Component<I<%= componentName %>Props, {}> {
7
7
  public render(): React.ReactElement<I<%= componentName %>Props> {
8
- const {
9
- description,
10
- isDarkTheme,
11
- environmentMessage,
12
- hasTeamsContext,
13
- userDisplayName
14
- } = this.props;
15
8
  return (
16
- <div className={ `${styles.<%= componentNameCamelCase %>} ${ hasTeamsContext ? styles.teams : '' }` }>
9
+ <div className={ styles.<%= componentNameCamelCase %> }>
17
10
  <div className={ styles.container }>
18
11
  <div className={ styles.row }>
19
- <div className={ `${ styles.column } ${ styles.center }` }>
20
- <img src={ isDarkTheme ? require('../assets/welcome-dark.png') : require('../assets/welcome-light.png') } className={ styles.welcomeImage } />
12
+ <div className={ styles.column }>
13
+ <span className={ styles.title }>Welcome to SharePoint!</span>
14
+ <p className={ styles.subTitle }>Customize SharePoint experiences using Web Parts.</p>
15
+ <p className={ styles.description }>{escape(this.props.description)}</p>
16
+ <a href="https://aka.ms/spfx" className={ styles.button }>
17
+ <span className={ styles.label }>Learn more</span>
18
+ </a>
21
19
  </div>
22
20
  </div>
23
- <div className={ styles.row }>
24
- <div className={ `${styles.column} ${styles.center}` }>
25
- <span className={ styles.title }>Well done, {userDisplayName}!</span>
26
- <p className={ styles.subTitle }>{environmentMessage}</p>
27
- <p className={ styles.subTitle }>Web part property value: <span className={ styles.description }>{escape(description)}</span></p>
28
- </div>
29
- </div>
30
- <div className={ styles.row }>
31
- <div className={ styles.column }>
32
- <span className={ styles.header }>Welcome to SharePoint Framework!</span>
33
- <p className={ styles.content }>
34
- The SharePoint Framework (SPFx) is a extensibility model for Microsoft Viva, Microsoft Teams and SharePoint. It's the easiest way to extend Microsoft 365 with automatic Single Sign On, automatic hosting and industry standard tooling.
35
- </p>
36
- <span className={ styles.subheader }>Learn more about SPFx development:</span>
37
- <p className={ styles.content }>
38
- <ul>
39
- <li><a className={ styles.link } href="https://aka.ms/spfx" target="_blank">Overview of the SharePoint Framework</a></li>
40
- <li><a className={ styles.link } href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/notes-on-solution-packaging" target="_blank">SharePoint solution packaging</a></li>
41
- <li><a className={ styles.link } href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview" target="_blank">Build for Microsoft Teams using SharePoint Framework</a></li>
42
- <li><a className={ styles.link } href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/use-fabric-react-components" target="_blank">Use Fluent UI components in your SharePoint client-side web part</a></li>
43
- <li><a className={ styles.link } href="https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis" target="_blank">Use Microsoft Graph in your solution</a></li>
44
- <li><a className={ styles.link } href="https://docs.microsoft.com/en-us/javascript/api/overview/sharepoint?view=sp-typescript-latest" target="_blank">SharePoint Framework API reference</a></li>
45
- <li><a className={ styles.link } href="https://aka.ms/m365pnp" target="_blank">Microsoft 365 Community Assets - Calls, samples and documentation</a></li>
46
- <li><a className={ styles.link } href="https://aka.ms/m365/devprogram" target="_blank">Register to Microsoft 365 Developer program for a free developer tenant</a></li>
47
- </ul>
48
- </p>
49
- </div>
50
- </div>
51
21
  </div>
52
22
  </div>
53
23
  );
@@ -6,12 +6,6 @@ import {
6
6
  PropertyPaneTextField
7
7
  } from '@microsoft/sp-property-pane';
8
8
  import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
9
- import {
10
- ThemeProvider,
11
- ThemeChangedEventArgs,
12
- IReadonlyTheme,
13
- ITheme
14
- } from '@microsoft/sp-component-base';
15
9
 
16
10
  import * as strings from '<%= componentStrings %>';
17
11
  import <%= componentName %> from './components/<%= componentName %>';
@@ -23,150 +17,19 @@ export interface I<%= componentClassName %>Props {
23
17
 
24
18
  export default class <%= componentClassName %> extends BaseClientSideWebPart<I<%= componentClassName %>Props> {
25
19
 
26
- private _themeProvider: ThemeProvider;
27
- private _themeVariant: IReadonlyTheme | undefined;
28
- private _isDarkTheme: boolean = false;
29
- private _environmentMessage: string = '';
30
- private _hasTeamsContext: boolean = false;
31
-
32
- protected onInit(): Promise<void> {
33
- this._hasTeamsContext = !!this.context.sdks.microsoftTeams;
34
-
35
- if (this._hasTeamsContext) {
36
- // handling MS Teams theme
37
- const teamsTheme = this.context.sdks.microsoftTeams.context.theme;
38
- this._updateTheme(teamsTheme);
39
-
40
- this.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler(this._handleTeamsThemeChangedEvent);
41
- }
42
- else {
43
- // Consume the new ThemeProvider service
44
- this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
45
-
46
- // If it exists, get the theme variant
47
- this._themeVariant = this._themeProvider.tryGetTheme();
48
- this._updateTheme(this._themeVariant);
49
-
50
- // Register a handler to be notified if the theme variant changes
51
- this._themeProvider.themeChangedEvent.add(this, this._handleSPThemeChangedEvent);
52
- }
53
-
54
- this._environmentMessage = this._getEnvironmentMessage();
55
-
56
- return super.onInit();
57
- }
58
-
59
20
  public render(): void {
60
21
  const element: React.ReactElement<I<%= componentName %>Props> = React.createElement(
61
22
  <%= componentName %>,
62
23
  {
63
- description: this.properties.description,
64
- isDarkTheme: this._isDarkTheme,
65
- environmentMessage: this._environmentMessage,
66
- hasTeamsContext: this._hasTeamsContext,
67
- userDisplayName: this.context.pageContext.user.displayName
24
+ description: this.properties.description
68
25
  }
69
26
  );
70
27
 
71
28
  ReactDom.render(element, this.domElement);
72
29
  }
73
30
 
74
- /**
75
- * Update the current theme variant reference and re-render.
76
- *
77
- * @param args The new theme
78
- */
79
- private _handleSPThemeChangedEvent = (args: ThemeChangedEventArgs): void => {
80
- this._themeVariant = args.theme;
81
- this._updateTheme(this._themeVariant);
82
- this.render();
83
- }
84
-
85
- /**
86
- * Handle Teams theme change callback.
87
- *
88
- * @param args The new theme
89
- */
90
- private _handleTeamsThemeChangedEvent = (theme: string): void => {
91
- this._updateTheme(theme);
92
- this.render();
93
- }
94
-
95
- /**
96
- * Updates fields based on the new theme
97
- * @param currentTheme updated theme
98
- */
99
- private _updateTheme = (currentTheme: IReadonlyTheme | string) => {
100
- this._setIsDarkTheme(currentTheme);
101
- this._setCSSVariables();
102
- }
103
-
104
- /**
105
- * Updates the _isDarkTheme based on current SharePoint or Teams theme
106
- */
107
- private _setIsDarkTheme = (currentTheme: IReadonlyTheme | string) => {
108
- if (typeof currentTheme === 'string') { // Teams theme
109
- this._isDarkTheme = currentTheme !== 'default'; // contrast theme is interpreted as dark
110
- }
111
- else { // SharePoint theme
112
- const theme = currentTheme as ITheme;
113
- this._isDarkTheme = !!theme && !!theme.isInverted;
114
- }
115
- }
116
-
117
- private _setCSSVariables = () => {
118
- let primaryText = '#323130'; // default
119
- let linkText = '#03787c';
120
- if (this._themeVariant) {
121
- const {
122
- semanticColors
123
- } = this._themeVariant;
124
- primaryText = semanticColors.bodyText;
125
- linkText = semanticColors.link;
126
- }
127
- else if (this._hasTeamsContext) { // fallback for Teams
128
- primaryText = this._isDarkTheme ? '#FFFFFF' : '#242424';
129
- linkText = this._isDarkTheme ? '#FFFFFF' : '#494B83';
130
- }
131
- else { // fallback for single app page
132
- primaryText = this._isDarkTheme ? '#3a96dd' : '#323130';
133
- linkText = this._isDarkTheme ? '#3a96dd' : '#03787c';
134
- }
135
-
136
- this.domElement.style.setProperty('--primaryText', primaryText);
137
- this.domElement.style.setProperty('--linkText', linkText);
138
- }
139
-
140
- private _getEnvironmentMessage = (): string => {
141
- // checking for local environment
142
- let isLocal: boolean = false;
143
- const {
144
- loaderConfig
145
- } = this.manifest;
146
-
147
- if (loaderConfig && loaderConfig.internalModuleBaseUrls && loaderConfig.internalModuleBaseUrls.length) {
148
- isLocal = /^http(s)?\:\/\/localhost/gmi.test(loaderConfig.internalModuleBaseUrls[0]);
149
- }
150
-
151
- if (this._hasTeamsContext) { // running in Teams
152
- return isLocal ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
153
- }
154
-
155
- return isLocal ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment;
156
- }
157
-
158
31
  protected onDispose(): void {
159
32
  ReactDom.unmountComponentAtNode(this.domElement);
160
-
161
- //
162
- // unregistering theme changed handlers
163
- //
164
- if (this._hasTeamsContext) {
165
- this.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler(null);
166
- }
167
- else {
168
- this._themeProvider.themeChangedEvent.remove(this, this._handleSPThemeChangedEvent);
169
- }
170
33
  }
171
34
 
172
35
  protected get dataVersion(): Version {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/generator-sharepoint",
3
- "version": "1.13.0-beta.19",
3
+ "version": "1.13.0-rc.1",
4
4
  "description": "Yeoman generator for the SharePoint Framework",
5
5
  "scripts": {},
6
6
  "engines": {
@@ -13,13 +13,13 @@
13
13
  "homepage": "http://aka.ms/spfx",
14
14
  "main": "lib/generators/app/index.js",
15
15
  "dependencies": {
16
- "@microsoft/spfx-heft-plugins": "1.13.0-beta.19",
16
+ "@microsoft/spfx-heft-plugins": "1.13.0-rc.1",
17
17
  "@rushstack/node-core-library": "3.40.0",
18
18
  "colors": "~1.2.1",
19
19
  "lodash": "4.17.21",
20
- "update-notifier": "~2.6.0",
20
+ "update-notifier": "5.1.0",
21
21
  "uuid": "~3.1.0",
22
- "yeoman-generator": "5.0.0",
22
+ "yeoman-generator": "5.4.2",
23
23
  "yosay": "2.0.2"
24
24
  }
25
25
  }
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
3
- "deployCdnPath": "./release/assets/"
4
- }