Add 'samples/react-ppw-html/' from commit '1d033d0348cda84f2cd1d524b4a853c997d1f767'
git-subtree-dir: samples/react-ppw-html git-subtree-mainline:120045d287
git-subtree-split:1d033d0348
|
@ -0,0 +1,33 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
release
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Hosted workbench",
|
||||
"type": "pwa-chrome",
|
||||
"request": "launch",
|
||||
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
|
||||
"webRoot": "${workspaceRoot}",
|
||||
"sourceMaps": true,
|
||||
"sourceMapPathOverrides": {
|
||||
"webpack:///.././src/*": "${webRoot}/src/*",
|
||||
"webpack:///../../../src/*": "${webRoot}/src/*",
|
||||
"webpack:///../../../../src/*": "${webRoot}/src/*",
|
||||
"webpack:///../../../../../src/*": "${webRoot}/src/*"
|
||||
},
|
||||
"runtimeArgs": [
|
||||
"--remote-debugging-port=9222",
|
||||
"-incognito"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
// Configure glob patterns for excluding files and folders in the file explorer.
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.DS_Store": true,
|
||||
"**/bower_components": true,
|
||||
"**/coverage": true,
|
||||
"**/lib-amd": true,
|
||||
"src/**/*.scss.ts": true
|
||||
},
|
||||
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"plusBeta": true,
|
||||
"isCreatingSolution": true,
|
||||
"version": "1.14.0-beta.5",
|
||||
"libraryName": "react-ppw-html",
|
||||
"libraryId": "32f04ff0-07c9-4fee-ab26-b488c8f651fa",
|
||||
"environment": "spo",
|
||||
"packageManager": "npm",
|
||||
"solutionName": "react-ppw-html",
|
||||
"solutionShortDescription": "react-ppw-html description",
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
yo
|
||||
npm i property-pane-wrap
|
||||
add properties to IHelloWorldWebPartProps
|
||||
add default property values to HelloWorldWebPart.manifest.json
|
|
@ -0,0 +1,70 @@
|
|||
# React-PPW-HTML
|
||||
|
||||
## Applies to
|
||||
|
||||
- [SharePoint Framework](https://aka.ms/spfx)
|
||||
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
|
||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||
|
||||
## Summary
|
||||
|
||||
The React-PPW-HTML sample showcases the use of the [Property Pane Wrap](https://www.npmjs.com/package/property-pane-wrap) to embed HTML controls in the SPFx Property Pane.
|
||||
|
||||
![React PPW HTML Sample](./assets/React-PPW-HTML-Sample.png)
|
||||
## Compatibility
|
||||
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
|
||||
![1.14.0.beta.5](https://img.shields.io/badge/version-1.14.0.beta.5-green.svg)
|
||||
|
||||
## Solution
|
||||
|
||||
Solution|Author(s)
|
||||
--------|---------
|
||||
React-PPW-HTML | [Christophe Humbert](https://github.com/PathToSharePoint)
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
0.1.0|February 8, 2022|Initial release
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
N/A
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Clone this repository
|
||||
- Ensure that you are at the solution folder
|
||||
- in the command-line run:
|
||||
- **npm install**
|
||||
- **gulp serve**
|
||||
|
||||
## Features
|
||||
|
||||
The sample web part illustrates the following concepts on top of the SharePoint Framework:
|
||||
- [Property Pane Wrap](https://www.npmjs.com/package/property-pane-wrap) for insertion of components in the Property Pane
|
||||
- HTML controlled and uncontrolled components in the Property Pane
|
||||
- HTML5 validity check
|
||||
- Control interdependencies (End Date >= Start Date)
|
||||
|
||||
## References
|
||||
|
||||
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
After Width: | Height: | Size: 227 KiB |
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"hello-world-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/helloWorld/HelloWorldWebPart.js",
|
||||
"manifest": "./src/webparts/helloWorld/HelloWorldWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"HelloWorldWebPartStrings": "lib/webparts/helloWorld/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-ppw-html",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-ppw-html-client-side-solution",
|
||||
"id": "32f04ff0-07c9-4fee-ab26-b488c8f651fa",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"developer": {
|
||||
"name": "Christophe Humbert",
|
||||
"websiteUrl": "",
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "Undefined-1.14.0-beta.5"
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "react-ppw-html description"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "react-ppw-html description"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "react-ppw-html Feature",
|
||||
"description": "The feature that activates elements of the react-ppw-html solution.",
|
||||
"id": "183a5d23-8799-4cd2-a67c-576fd323270b",
|
||||
"version": "1.0.0.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-ppw-html.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
build.initialize(require('gulp'));
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "react-ppw-html",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.14.0-beta.5",
|
||||
"@microsoft/sp-lodash-subset": "1.14.0-beta.5",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.14.0-beta.5",
|
||||
"@microsoft/sp-property-pane": "1.14.0-beta.5",
|
||||
"@microsoft/sp-webpart-base": "1.14.0-beta.5",
|
||||
"office-ui-fabric-react": "7.174.1",
|
||||
"property-pane-wrap": "^0.3.0",
|
||||
"react": "16.13.1",
|
||||
"react-dom": "16.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "16.9.51",
|
||||
"@types/react-dom": "16.9.8",
|
||||
"@microsoft/sp-build-web": "1.14.0-beta.5",
|
||||
"@microsoft/sp-tslint-rules": "1.14.0-beta.5",
|
||||
"@microsoft/sp-module-interfaces": "1.14.0-beta.5",
|
||||
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
|
||||
"gulp": "~4.0.2",
|
||||
"ajv": "~5.2.2",
|
||||
"@types/webpack-env": "1.13.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "6cb508f6-527c-4b6d-82d5-5337e28b2b63",
|
||||
"alias": "HelloWorldWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "Other" },
|
||||
"title": { "default": "Property Pane HTML Controls" },
|
||||
"description": { "default": "Use of the Property Pane Wrap (PPW) to insert HTML controls in the Property Pane." },
|
||||
"officeFabricIconFontName": "PageHeaderEdit",
|
||||
"properties": {
|
||||
"description": "Property Pane Wrap",
|
||||
"fieldsetDatesInput": ["", ""],
|
||||
"fieldsetColorInput": "#008080",
|
||||
"fieldsetCheckbox": true,
|
||||
"fieldsetCascadingSelect": ["", ""]
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
.urlInput {
|
||||
width: 100%;
|
||||
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
box-shadow: none;
|
||||
margin: 0px;
|
||||
padding: 0px 8px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0px;
|
||||
border: none;
|
||||
background: none transparent;
|
||||
color: rgb(255, 255, 255);
|
||||
width: 100%;
|
||||
min-width: 0px;
|
||||
text-overflow: ellipsis;
|
||||
outline: 0px;
|
||||
box-shadow: none;
|
||||
margin: 0px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgb(208, 208, 208);
|
||||
border-radius: 2px;
|
||||
background: rgb(24, 37, 52);
|
||||
height: 32px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
&:invalid {
|
||||
border: 1px solid red;
|
||||
}
|
||||
}
|
||||
|
||||
.fieldset {
|
||||
border: none;
|
||||
padding: 0!important;
|
||||
width: 100%;
|
||||
input {
|
||||
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
box-shadow: none;
|
||||
margin: 0px;
|
||||
padding: 0px 8px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0px;
|
||||
border: none;
|
||||
background: none transparent;
|
||||
color: rgb(255, 255, 255);
|
||||
width: 100%;
|
||||
min-width: 0px;
|
||||
text-overflow: ellipsis;
|
||||
outline: 0px;
|
||||
box-shadow: none;
|
||||
margin: 0px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgb(208, 208, 208);
|
||||
border-radius: 2px;
|
||||
background: rgb(24, 37, 52);
|
||||
height: 32px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
&:invalid {
|
||||
border: 1px solid red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fieldsetDatesInput {
|
||||
display: flex!important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
input[type=date] {
|
||||
width: 139px!important;
|
||||
padding: 4px!important;
|
||||
&::-webkit-datetime-edit-text {
|
||||
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
&::-webkit-calendar-picker-indicator {
|
||||
background: teal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fieldsetColorInput {
|
||||
input {
|
||||
width:100%;
|
||||
}
|
||||
}
|
||||
|
||||
.fieldsetCheckbox {
|
||||
width: 100%;
|
||||
display: flex!important;
|
||||
align-items: center;
|
||||
input {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.fieldsetCheckboxDarkLight {
|
||||
--black: #333333;
|
||||
--white: #f5f5f5;
|
||||
--backround: var(--white);
|
||||
--foreground: var(--black);
|
||||
--transition: 0.5s ease;
|
||||
width: 100%;
|
||||
display: flex!important;
|
||||
align-items: center;
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
input[type="checkbox"] + div {
|
||||
height: 37px;
|
||||
width: 80px;
|
||||
background: var(--black);
|
||||
border-radius: 30px;
|
||||
padding: 2px;
|
||||
position: relative;
|
||||
transition: background var(--transition);
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--white);
|
||||
}
|
||||
input[type="checkbox"]:checked + div {
|
||||
background: var(--white);
|
||||
}
|
||||
input[type="checkbox"] + div span::before {
|
||||
content: "";
|
||||
display: block;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
border-radius: 30px;
|
||||
padding: 2px;
|
||||
background: var(--white);
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
transform: translate(0);
|
||||
transition: transform var(--transition), background var(--transition);
|
||||
}
|
||||
input[type="checkbox"]:checked + div span::before {
|
||||
background: var(--black);
|
||||
}
|
||||
input[type="checkbox"]:checked + div span::before {
|
||||
transform: translateX(44px);
|
||||
}
|
||||
input[type="checkbox"] {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
}
|
||||
div div {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
input[type="checkbox"] + div div svg {
|
||||
padding: 6px;
|
||||
fill: var(--white);
|
||||
z-index: 0;
|
||||
}
|
||||
input[type="checkbox"]:checked + div div svg {
|
||||
fill: var(--black);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneHorizontalRule,
|
||||
PropertyPaneLabel,
|
||||
PropertyPaneSlider,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
import * as strings from 'HelloWorldWebPartStrings';
|
||||
import HelloWorld from './components/HelloWorld';
|
||||
import { IHelloWorldProps } from './components/IHelloWorldProps';
|
||||
import { PropertyPaneWrap } from 'property-pane-wrap';
|
||||
import { update } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
import styles from './HelloWorldWebPart.module.scss';
|
||||
import { MoonIcon, SunIcon } from './components/SVGIcons';
|
||||
|
||||
export interface IHelloWorldWebPartProps {
|
||||
description: string;
|
||||
fieldsetColorInput: string;
|
||||
fieldsetDatesInput: string[];
|
||||
fieldsetRangeInput: string;
|
||||
fieldsetURLInput: string;
|
||||
fieldsetCheckboxDarkLight: boolean;
|
||||
fieldsetCheckbox: boolean;
|
||||
fieldsetCascadingSelect: string[];
|
||||
}
|
||||
|
||||
export default class HelloWorldWebPart extends BaseClientSideWebPart<IHelloWorldWebPartProps> {
|
||||
|
||||
private _isDarkTheme: boolean = false;
|
||||
private _environmentMessage: string = '';
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
this._environmentMessage = this._getEnvironmentMessage();
|
||||
|
||||
return super.onInit();
|
||||
}
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IHelloWorldProps> = React.createElement(
|
||||
HelloWorld,
|
||||
{
|
||||
properties: this.properties,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
userDisplayName: this.context.pageContext.user.displayName
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
private _getEnvironmentMessage(): string {
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams
|
||||
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||
}
|
||||
|
||||
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment;
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
const {
|
||||
semanticColors
|
||||
} = currentTheme;
|
||||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText);
|
||||
this.domElement.style.setProperty('--link', semanticColors.link);
|
||||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered);
|
||||
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
public updateWebPartProperty(property, value, refreshWebPart = true, refreshPropertyPane = true) {
|
||||
|
||||
update(this.properties, property, () => value);
|
||||
if (refreshWebPart) this.render();
|
||||
if (refreshPropertyPane) this.context.propertyPane.refresh();
|
||||
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: "HTML Controls",
|
||||
groupFields: [
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetColorInput', { text: 'Color Input' }),
|
||||
PropertyPaneWrap('fieldsetColorInput', {
|
||||
component: () =>
|
||||
<fieldset className={`${styles.fieldset} ${styles.fieldsetColorInput}`}>
|
||||
<input
|
||||
type="color"
|
||||
defaultValue={this.properties["fieldsetColorInput"]}
|
||||
onChange={(e: any) => this.updateWebPartProperty("fieldsetColorInput", e.target.value, true, false)}
|
||||
></input>
|
||||
</fieldset>
|
||||
}),
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetDatesInput', { text: 'Date Input (Start, End)' }),
|
||||
PropertyPaneWrap('fieldsetDatesInput', {
|
||||
component: () =>
|
||||
<fieldset className={`${styles.fieldset} ${styles.fieldsetDatesInput}`}>
|
||||
<input
|
||||
type="date"
|
||||
defaultValue={this.properties["fieldsetDatesInput"][0]}
|
||||
max={this.properties["fieldsetDatesInput"][1]}
|
||||
onChange={(e: any) => e.target.checkValidity() && this.updateWebPartProperty("fieldsetDatesInput", [e.target.value, this.properties["fieldsetDatesInput"][1]], true)}
|
||||
></input>
|
||||
<input
|
||||
type="date"
|
||||
defaultValue={this.properties["fieldsetDatesInput"][1]}
|
||||
min={this.properties["fieldsetDatesInput"][0]}
|
||||
onChange={(e: any) => e.target.checkValidity() && this.updateWebPartProperty("fieldsetDatesInput", [this.properties["fieldsetDatesInput"][0], e.target.value], true)}
|
||||
></input>
|
||||
</fieldset>
|
||||
}),
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetRangeInput', { text: 'Range Input' }),
|
||||
PropertyPaneWrap('fieldsetRangeInput', {
|
||||
component: () =>
|
||||
<fieldset className={`${styles.fieldset}`}>
|
||||
<input
|
||||
type="range"
|
||||
list={`tickmarks-fieldsetRangeInput-${this.instanceId}`}
|
||||
defaultValue={this.properties["fieldsetRangeInput"]}
|
||||
onChange={(e: any) => this.updateWebPartProperty("fieldsetRangeInput", e.target.value)}
|
||||
></input>
|
||||
<datalist id={`tickmarks-fieldsetRangeInput-${this.instanceId}`}>
|
||||
<option value="0" label="0"></option>
|
||||
<option value="25" label="25"></option>
|
||||
<option value="50" label="50"></option>
|
||||
<option value="75" label="75"></option>
|
||||
<option value="100" label="100"></option>
|
||||
</datalist>
|
||||
</fieldset>
|
||||
}),
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetURLInput', { text: 'SharePoint Online Site URL' }),
|
||||
PropertyPaneWrap('fieldsetURLInput', {
|
||||
component: (props) => <input {...props} />,
|
||||
props: {
|
||||
className: styles.urlInput,
|
||||
type: "url",
|
||||
defaultValue: this.properties["fieldsetURLInput"],
|
||||
placeholder: "https://tenant.sharepoint.com/sites/name",
|
||||
pattern: "https://.*\.sharepoint.com/sites/.+",
|
||||
onChange: (e: any) => {
|
||||
e.target.checkValidity() && this.updateWebPartProperty("fieldsetURLInput", e.target.value, true, false);
|
||||
}
|
||||
}
|
||||
}),
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetCheckboxDarkLight', { text: 'Checkbox as Toggle Button' }),
|
||||
PropertyPaneWrap('fieldsetCheckboxDarkLight', {
|
||||
component: () =>
|
||||
<label className={`${styles.fieldset} ${styles.fieldsetCheckboxDarkLight}`}>
|
||||
<input
|
||||
type="checkbox"
|
||||
defaultChecked={this.properties["fieldsetCheckboxDarkLight"]}
|
||||
onChange={(e: any) => this.updateWebPartProperty("fieldsetCheckboxDarkLight", e.target.checked, true, false)}
|
||||
></input>
|
||||
<div>
|
||||
<span>
|
||||
</span>
|
||||
<div>
|
||||
<SunIcon />
|
||||
<MoonIcon />
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
}),
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneLabel('fieldsetCheckbox', { text: 'Checkbox' }),
|
||||
PropertyPaneWrap('fieldsetCheckbox', {
|
||||
component: (props) =>
|
||||
<div className={styles.fieldsetCheckbox}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={this.properties["fieldsetCheckbox"]}
|
||||
onChange={(e: any) => this.updateWebPartProperty("fieldsetCheckbox", e.target.checked)}
|
||||
></input>
|
||||
<span>
|
||||
 {(this.properties["fieldsetCheckbox"]) ? "Checked" : "Unchecked"}
|
||||
</span>
|
||||
</div>
|
||||
}),
|
||||
]
|
||||
},
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneHorizontalRule(),
|
||||
PropertyPaneTextField('description', {
|
||||
label: strings.PropertyPaneTextFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <fieldset data-property="fieldsetCascadingSelect" >
|
||||
// <label>Cascading Select</label>
|
||||
// <div className="flexControl">
|
||||
// <select
|
||||
// className='select-css'
|
||||
// value={this.properties["fieldsetCascadingSelect"][0]}
|
||||
// onChange={(e: any) => {
|
||||
// this.updateWebPartProperty("fieldsetCascadingSelect", [e.target.value, ""]);
|
||||
// }
|
||||
// }
|
||||
// >
|
||||
// <option value="">Select Family...</option>
|
||||
// {familiesList
|
||||
// .map(item => <option value={item.value}>{item.name}</option>)}
|
||||
// </select>
|
||||
// <select
|
||||
// className='select-css'
|
||||
// value={this.properties["fieldsetCascadingSelect"][1]}
|
||||
// onChange={(e: any) => this.updateWebPartProperty("fieldsetCascadingSelect", [this.properties["fieldsetCascadingSelect"][0], e.target.value])}
|
||||
// >
|
||||
// <option value="">Select App...</option>
|
||||
// {(this.properties["fieldsetCascadingSelect"]) && appsList
|
||||
// .filter(i => i.parent == this.properties["fieldsetCascadingSelect"][0])
|
||||
// .map(item => <option value={item.value}>{item.name}</option>)}
|
||||
// </select>
|
||||
// </div>
|
||||
// </fieldset>
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 11.807C10.7418 10.5483 9.88488 8.94484 9.53762 7.1993C9.19037 5.45375 9.36832 3.64444 10.049 2C8.10826 2.38205 6.3256 3.33431 4.92899 4.735C1.02399 8.64 1.02399 14.972 4.92899 18.877C8.83499 22.783 15.166 22.782 19.072 18.877C20.4723 17.4805 21.4245 15.6983 21.807 13.758C20.1625 14.4385 18.3533 14.6164 16.6077 14.2692C14.8622 13.9219 13.2588 13.0651 12 11.807V11.807Z" />
|
||||
</svg>
|
After Width: | Height: | Size: 489 B |
|
@ -0,0 +1,7 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.995 12C6.995 14.761 9.241 17.007 12.002 17.007C14.763 17.007 17.009 14.761 17.009 12C17.009 9.239 14.763 6.993 12.002 6.993C9.241 6.993 6.995 9.239 6.995 12ZM11 19H13V22H11V19ZM11 2H13V5H11V2ZM2 11H5V13H2V11ZM19 11H22V13H19V11Z" />
|
||||
<path d="M5.63702 19.778L4.22302 18.364L6.34402 16.243L7.75802 17.657L5.63702 19.778Z" />
|
||||
<path d="M16.242 6.34405L18.364 4.22205L19.778 5.63605L17.656 7.75805L16.242 6.34405Z" />
|
||||
<path d="M6.34402 7.75902L4.22302 5.63702L5.63802 4.22302L7.75802 6.34502L6.34402 7.75902Z" />
|
||||
<path d="M19.778 18.3639L18.364 19.7779L16.242 17.6559L17.656 16.2419L19.778 18.3639Z" />
|
||||
</svg>
|
After Width: | Height: | Size: 711 B |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,46 @@
|
|||
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||
|
||||
.helloWorld {
|
||||
overflow: hidden;
|
||||
padding: 1em;
|
||||
color: "[theme:bodyText, default: #323130]";
|
||||
color: var(--bodyText);
|
||||
&.teams {
|
||||
font-family: $ms-font-family-fallbacks;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcomeImage {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.links {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: "[theme:link, default:#03787c]";
|
||||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: "[theme:linkHovered, default: #014446]";
|
||||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.propertyTable {
|
||||
border-collapse: collapse;
|
||||
th {
|
||||
padding: 10px;
|
||||
}
|
||||
td {
|
||||
text-align: left;
|
||||
border: 1px solid teal;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import * as React from 'react';
|
||||
import styles from './HelloWorld.module.scss';
|
||||
import { IHelloWorldProps } from './IHelloWorldProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
export default class HelloWorld extends React.Component<IHelloWorldProps, {}> {
|
||||
public render(): React.ReactElement<IHelloWorldProps> {
|
||||
const {
|
||||
properties,
|
||||
isDarkTheme,
|
||||
environmentMessage,
|
||||
hasTeamsContext,
|
||||
userDisplayName
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<section className={`${styles.helloWorld} ${hasTeamsContext ? styles.teams : ''}`}>
|
||||
<div className={styles.welcome}>
|
||||
<h2>Select the Edit button to open the Property Pane.</h2>
|
||||
<img alt="" src={isDarkTheme ? require('../assets/welcome-dark.png') : require('../assets/welcome-light.png')} className={styles.welcomeImage} />
|
||||
<h2>Well done, {escape(userDisplayName)}!</h2>
|
||||
<div>{environmentMessage}</div>
|
||||
<table className={styles.propertyTable}>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
{Object.keys(properties).map(key => {
|
||||
return (
|
||||
<tr key={key}>
|
||||
<td>{key}</td>
|
||||
<td><strong>{escape(properties[key])}</strong></td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Welcome to SharePoint Framework!</h3>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<h4>Learn more about SPFx development:</h4>
|
||||
<ul className={styles.links}>
|
||||
<li><a href="https://aka.ms/spfx" target="_blank">SharePoint Framework Overview</a></li>
|
||||
<li><a href="https://aka.ms/spfx-yeoman-graph" target="_blank">Use Microsoft Graph in your solution</a></li>
|
||||
<li><a href="https://aka.ms/spfx-yeoman-teams" target="_blank">Build for Microsoft Teams using SharePoint Framework</a></li>
|
||||
<li><a href="https://aka.ms/spfx-yeoman-viva" target="_blank">Build for Microsoft Viva Connections using SharePoint Framework</a></li>
|
||||
<li><a href="https://aka.ms/spfx-yeoman-store" target="_blank">Publish SharePoint Framework applications to the marketplace</a></li>
|
||||
<li><a href="https://aka.ms/spfx-yeoman-api" target="_blank">SharePoint Framework API reference</a></li>
|
||||
<li><a href="https://aka.ms/m365pnp" target="_blank">Microsoft 365 Developer Community</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface IHelloWorldProps {
|
||||
properties: object;
|
||||
isDarkTheme: boolean;
|
||||
environmentMessage: string;
|
||||
hasTeamsContext: boolean;
|
||||
userDisplayName: string;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
import * as React from 'react';
|
||||
|
||||
const SunIcon: React.FunctionComponent = () => {
|
||||
return (
|
||||
<>
|
||||
{/* sgv sun icon */}
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.995 12C6.995 14.761 9.241 17.007 12.002 17.007C14.763 17.007 17.009 14.761 17.009 12C17.009 9.239 14.763 6.993 12.002 6.993C9.241 6.993 6.995 9.239 6.995 12ZM11 19H13V22H11V19ZM11 2H13V5H11V2ZM2 11H5V13H2V11ZM19 11H22V13H19V11Z" />
|
||||
<path d="M5.63702 19.778L4.22302 18.364L6.34402 16.243L7.75802 17.657L5.63702 19.778Z" />
|
||||
<path d="M16.242 6.34405L18.364 4.22205L19.778 5.63605L17.656 7.75805L16.242 6.34405Z" />
|
||||
<path d="M6.34402 7.75902L4.22302 5.63702L5.63802 4.22302L7.75802 6.34502L6.34402 7.75902Z" />
|
||||
<path d="M19.778 18.3639L18.364 19.7779L16.242 17.6559L17.656 16.2419L19.778 18.3639Z" />
|
||||
</svg>
|
||||
</>
|
||||
);
|
||||
};
|
||||
const MoonIcon: React.FunctionComponent = () => {
|
||||
return (
|
||||
<>
|
||||
{/* svg moon icon */}
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 11.807C10.7418 10.5483 9.88488 8.94484 9.53762 7.1993C9.19037 5.45375 9.36832 3.64444 10.049 2C8.10826 2.38205 6.3256 3.33431 4.92899 4.735C1.02399 8.64 1.02399 14.972 4.92899 18.877C8.83499 22.783 15.166 22.782 19.072 18.877C20.4723 17.4805 21.4245 15.6983 21.807 13.758C20.1625 14.4385 18.3533 14.6164 16.6077 14.2692C14.8622 13.9219 13.2588 13.0651 12 11.807V11.807Z" />
|
||||
</svg>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export { SunIcon, MoonIcon };
|
|
@ -0,0 +1,11 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Property Pane Wrap for HTML Controls",
|
||||
"BasicGroupName": "Standard Field",
|
||||
"PropertyPaneTextFieldLabel": "PropertyPaneTextField",
|
||||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
declare interface IHelloWorldWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
PropertyPaneTextFieldLabel: string;
|
||||
AppLocalEnvironmentSharePoint: string;
|
||||
AppLocalEnvironmentTeams: string;
|
||||
AppSharePointEnvironment: string;
|
||||
AppTeamsTabEnvironment: string;
|
||||
}
|
||||
|
||||
declare module 'HelloWorldWebPartStrings' {
|
||||
const strings: IHelloWorldWebPartStrings;
|
||||
export = strings;
|
||||
}
|
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 542 B |
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noUnusedLocals": false,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|