mgwdev-m365-components 0.0.2 → 0.0.4
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.
- package/.env +2 -0
- package/.env.development +2 -0
- package/.eslintrc.cjs +18 -0
- package/build/assets/index-SHI6Sf4K.js +123 -0
- package/build/index.html +13 -0
- package/build/manifest.webmanifest +1 -0
- package/build/registerSW.js +1 -0
- package/build/sw.js +1 -0
- package/build/vite.svg +1 -0
- package/build/workbox-7cfec069.js +1 -0
- package/gulpfile.js +4 -0
- package/index.html +13 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +212 -0
- package/lib/components/Test.d.ts +4 -0
- package/lib/components/Test.js +37 -0
- package/lib/components/common/GraphPersona.d.ts +10 -0
- package/lib/components/common/GraphPersona.js +125 -0
- package/lib/components/common/graphEntityPicker/AbstractGraphEntityPicker.d.ts +16 -0
- package/lib/components/common/graphEntityPicker/AbstractGraphEntityPicker.js +117 -0
- package/lib/components/common/graphEntityPicker/ChannelPicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/ChannelPicker.js +83 -0
- package/lib/components/common/graphEntityPicker/DrivePicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/DrivePicker.js +77 -0
- package/lib/components/common/graphEntityPicker/ListPicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/ListPicker.js +77 -0
- package/lib/components/common/graphEntityPicker/PeoplePicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/PeoplePicker.js +76 -0
- package/lib/components/common/graphEntityPicker/SitePicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/SitePicker.js +73 -0
- package/lib/components/common/graphEntityPicker/TeamPicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/TeamPicker.js +77 -0
- package/lib/components/common/graphEntityPicker/index.d.ts +6 -0
- package/lib/components/common/graphEntityPicker/index.js +6 -0
- package/lib/components/common/index.d.ts +2 -0
- package/lib/components/common/index.js +2 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +2 -0
- package/lib/components/provisioning/GetSiteTemplate.d.ts +6 -0
- package/lib/components/provisioning/GetSiteTemplate.js +41 -0
- package/lib/components/search/DefaultDocumentCard.d.ts +7 -0
- package/lib/components/search/DefaultDocumentCard.js +59 -0
- package/lib/components/search/M365Search.d.ts +18 -0
- package/lib/components/search/M365Search.js +69 -0
- package/lib/components/search/SearchDefaults.d.ts +1 -0
- package/lib/components/search/SearchDefaults.js +17 -0
- package/lib/components/search/index.d.ts +2 -0
- package/lib/components/search/index.js +2 -0
- package/lib/context/AuthenticationContext.d.ts +11 -0
- package/lib/context/AuthenticationContext.js +50 -0
- package/lib/context/DataverseContext.d.ts +13 -0
- package/lib/context/DataverseContext.js +29 -0
- package/lib/context/GraphContext.d.ts +11 -0
- package/lib/context/GraphContext.js +26 -0
- package/lib/context/SPContext.d.ts +13 -0
- package/lib/context/SPContext.js +30 -0
- package/lib/context/index.d.ts +4 -0
- package/lib/context/index.js +4 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +6 -0
- package/lib/model/IEntityWithIdAndDisplayName.d.ts +4 -0
- package/lib/model/IEntityWithIdAndDisplayName.js +1 -0
- package/lib/model/ISearchResult.d.ts +19 -0
- package/lib/model/ISearchResult.js +1 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +1 -0
- package/lib/model/infra/ICacheEntry.d.ts +4 -0
- package/lib/model/infra/ICacheEntry.js +1 -0
- package/lib/service-worker/sw.d.ts +3 -0
- package/lib/service-worker/sw.js +20 -0
- package/lib/services/PersonaService.d.ts +12 -0
- package/lib/services/PersonaService.js +134 -0
- package/lib/utils/FileUtils.d.ts +29 -0
- package/lib/utils/FileUtils.js +200 -0
- package/lib/utils/StringUtils.d.ts +1 -0
- package/lib/utils/StringUtils.js +10 -0
- package/lib/utils/ThumbnailUtils.d.ts +7 -0
- package/lib/utils/ThumbnailUtils.js +92 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +3 -0
- package/package.json +1 -16
- package/public/vite.svg +1 -0
- package/tsconfig.json +35 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +33 -0
- package/vitest.config.ts +11 -0
package/build/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-SHI6Sf4K.js"></script>
|
|
9
|
+
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"mgwdev-m365-components","short_name":"mgwdev-m365-components","start_url":"/","display":"standalone","background_color":"#ffffff","lang":"en","scope":"/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('/sw.ts', { scope: '/' })})}
|
package/build/sw.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()})).then((()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e})));self.define=(n,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let o={};const f=e=>i(e,r),c={module:{uri:r},exports:o,require:f};s[r]=Promise.all(n.map((e=>c[e]||f(e)))).then((e=>(t(...e),o)))}}define(["./workbox-7cfec069"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.precacheAndRoute([{url:"assets/index-SHI6Sf4K.js",revision:null},{url:"index.html",revision:"5684ce7e16b6a8faa447cfa75fee020f"},{url:"registerSW.js",revision:"b5adf963134379464327d9ee6f22e054"},{url:"manifest.webmanifest",revision:"9972b2a343c74d7db2f3ccc2a22d0467"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}));
|
package/build/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
define(["exports"],(function(t){"use strict";try{self["workbox:core:7.0.0"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:7.0.0"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class i{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class r extends i{constructor(t,e,s){super((({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)}),e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",(t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map((e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})})));t.waitUntil(s),t.ports&&t.ports[0]&&s.then((()=>t.ports[0].postMessage(!0)))}}))}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=r&&r.handler;const c=t.method;if(!o&&this.i.has(c)&&(o=this.i.get(c)),!o)return;let a;try{a=o.handle({url:s,request:t,event:e,params:i})}catch(t){a=Promise.reject(t)}const h=r&&r.catchHandler;return a instanceof Promise&&(this.o||h)&&(a=a.catch((async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:i})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n}))),a}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const i=this.t.get(s.method)||[];for(const r of i){let i;const o=r.match({url:t,sameOrigin:e,request:s,event:n});if(o)return i=o,(Array.isArray(i)&&0===i.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(i=void 0),{route:r,params:i}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let c;const a=()=>(c||(c=new o,c.addFetchListener(),c.addCacheListener()),c);function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new i((({url:t})=>t.href===s.href),e,n)}else if(t instanceof RegExp)o=new r(t,e,n);else if("function"==typeof t)o=new i(t,e,n);else{if(!(t instanceof i))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return a().registerRoute(o),o}const u={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},l=t=>[u.prefix,t,u.suffix].filter((t=>t&&t.length>0)).join("-"),f=t=>t||l(u.precache),w=t=>t||l(u.runtime);function d(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:7.0.0"]&&_()}catch(t){}function p(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const i=new URL(n,location.href),r=new URL(n,location.href);return i.searchParams.set("__WB_REVISION__",e),{cacheKey:i.href,url:r.href}}class y{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class g{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=(null==e?void 0:e.cacheKey)||this.h.getCacheKeyForURL(t.url);return s?new Request(s,{headers:t.headers}):t},this.h=t}}let R;async function m(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const i=t.clone(),r={headers:new Headers(i.headers),status:i.status,statusText:i.statusText},o=e?e(r):r,c=function(){if(void 0===R){const t=new Response("");if("body"in t)try{new Response(t.body),R=!0}catch(t){R=!1}R=!1}return R}()?i.body:await i.blob();return new Response(c,o)}function v(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class q{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}const U=new Set;try{self["workbox:strategies:7.0.0"]&&_()}catch(t){}function L(t){return"string"==typeof t?new Request(t):t}class b{constructor(t,e){this.u={},Object.assign(this,e),this.event=e.event,this.l=t,this.p=new q,this.R=[],this.m=[...t.plugins],this.v=new Map;for(const t of this.m)this.v.set(t,{});this.event.waitUntil(this.p.promise)}async fetch(t){const{event:e}=this;let n=L(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const i=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const r=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.l.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:r,response:t});return t}catch(t){throw i&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:i.clone(),request:r.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=L(t);let s;const{cacheName:n,matchOptions:i}=this.l,r=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},i),{cacheName:n});s=await caches.match(r,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:i,cachedResponse:s,request:r,event:this.event})||void 0;return s}async cachePut(t,e){const n=L(t);var i;await(i=0,new Promise((t=>setTimeout(t,i))));const r=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(o=r.url,new URL(String(o),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var o;const c=await this.q(e);if(!c)return!1;const{cacheName:a,matchOptions:h}=this.l,u=await self.caches.open(a),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const i=v(e.url,s);if(e.url===i)return t.match(e,n);const r=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,r);for(const e of o)if(i===v(e.url,s))return t.match(e,n)}(u,r.clone(),["__WB_REVISION__"],h):null;try{await u.put(r,l?c.clone():c)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of U)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:a,oldResponse:f,newResponse:c.clone(),request:r,event:this.event});return!0}async getCacheKey(t,e){const s=`${t.url} | ${e}`;if(!this.u[s]){let n=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))n=L(await t({mode:e,request:n,event:this.event,params:this.params}));this.u[s]=n}return this.u[s]}hasCallback(t){for(const e of this.l.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.l.plugins)if("function"==typeof e[t]){const s=this.v.get(e),n=n=>{const i=Object.assign(Object.assign({},n),{state:s});return e[t](i)};yield n}}waitUntil(t){return this.R.push(t),t}async doneWaiting(){let t;for(;t=this.R.shift();)await t}destroy(){this.p.resolve(null)}async q(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class C{constructor(t={}){this.cacheName=w(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,i=new b(this,{event:e,request:s,params:n}),r=this.U(i,s,e);return[r,this.L(r,i,s,e)]}async U(t,e,n){let i;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(i=await this._(e,t),!i||"error"===i.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const r of t.iterateCallbacks("handlerDidError"))if(i=await r({error:s,event:n,request:e}),i)break;if(!i)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))i=await s({event:n,request:e,response:i});return i}async L(t,e,s,n){let i,r;try{i=await t}catch(r){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:i}),await e.doneWaiting()}catch(t){t instanceof Error&&(r=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:i,error:r}),e.destroy(),r)throw r}}class E extends C{constructor(t={}){t.cacheName=f(t.cacheName),super(t),this.C=!1!==t.fallbackToNetwork,this.plugins.push(E.copyRedirectedCacheableResponsesPlugin)}async _(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.O(t,e):await this.N(t,e))}async N(t,e){let n;const i=e.params||{};if(!this.C)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});{const s=i.integrity,r=t.integrity,o=!r||r===s;n=await e.fetch(new Request(t,{integrity:"no-cors"!==t.mode?r||s:void 0})),s&&o&&"no-cors"!==t.mode&&(this.k(),await e.cachePut(t,n.clone()))}return n}async O(t,e){this.k();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}k(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==E.copyRedirectedCacheableResponsesPlugin&&(n===E.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(E.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}E.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},E.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await m(t):t};class O{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.K=new Map,this.P=new Map,this.T=new Map,this.l=new E({cacheName:f(t),plugins:[...e,new g({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.l}precache(t){this.addToCacheList(t),this.W||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.W=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:i}=p(n),r="string"!=typeof n&&n.revision?"reload":"default";if(this.K.has(i)&&this.K.get(i)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.K.get(i),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.T.has(t)&&this.T.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:i});this.T.set(t,n.integrity)}if(this.K.set(i,t),this.P.set(i,r),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return d(t,(async()=>{const e=new y;this.strategy.plugins.push(e);for(const[e,s]of this.K){const n=this.T.get(s),i=this.P.get(e),r=new Request(e,{integrity:n,cache:i,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:r,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(t){return d(t,(async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.K.values()),n=[];for(const i of e)s.has(i.url)||(await t.delete(i),n.push(i.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this.K}getCachedURLs(){return[...this.K.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.K.get(e.href)}getIntegrityForCacheKey(t){return this.T.get(t)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}let x;const N=()=>(x||(x=new O),x);class k extends i{constructor(t,e){super((({request:s})=>{const n=t.getURLsToCacheKeys();for(const i of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:i}={}){const r=new URL(t,location.href);r.hash="",yield r.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some((t=>t.test(s)))&&t.searchParams.delete(s);return t}(r,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(i){const t=i({url:r});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(i);if(e){return{cacheKey:e,integrity:t.getIntegrityForCacheKey(e)}}}}),t.strategy)}}t.NavigationRoute=class extends i{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super((t=>this.j(t)),t),this.M=e,this.S=s}j({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.S)if(t.test(s))return!1;return!!this.M.some((t=>t.test(s)))}},t.cleanupOutdatedCaches=function(){self.addEventListener("activate",(t=>{const e=f();t.waitUntil((async(t,e="-precache-")=>{const s=(await self.caches.keys()).filter((s=>s.includes(e)&&s.includes(self.registration.scope)&&s!==t));return await Promise.all(s.map((t=>self.caches.delete(t)))),s})(e).then((t=>{})))}))},t.createHandlerBoundToURL=function(t){return N().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){N().precache(t)}(t),function(t){const e=N();h(new k(e,t))}(e)},t.registerRoute=h}));
|
package/gulpfile.js
ADDED
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/lib/App.d.ts
ADDED
package/lib/App.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AuthenticationContextProvider, GraphContextProvider, SPContextProvider } from './context';
|
|
3
|
+
import { DrivePicker, PeoplePicker, TeamPicker } from './components/common/graphEntityPicker';
|
|
4
|
+
import { SitePicker } from './components/common/graphEntityPicker/SitePicker';
|
|
5
|
+
import { Msal2AuthenticationService } from 'mgwdev-m365-helpers/lib/services/Msal2AuthenticationService';
|
|
6
|
+
import { ListPickerPicker } from './components/common/graphEntityPicker/ListPicker';
|
|
7
|
+
import { GetSiteTemplateContext } from './components/provisioning/GetSiteTemplate';
|
|
8
|
+
function App() {
|
|
9
|
+
var pnpSearchWPConfig = {
|
|
10
|
+
"queryTemplate": "{searchTerms}",
|
|
11
|
+
"selectedProperties": "Title,Path,Created,Filename,SiteLogo,PreviewUrl,PictureThumbnailURL,ServerRedirectedPreviewURL,ServerRedirectedURL,HitHighlightedSummary,FileType,contentclass,ServerRedirectedEmbedURL,ParentLink,DefaultEncodingURL,owstaxidmetadataalltagsinfo,Author,AuthorOWSUSER,SPSiteUrl,SiteTitle,IsContainer,IsListItem,HtmlFileType,SiteId,WebId,UniqueID,OriginalPath,FileExtension,IsDocument,NormSiteID,NormWebID,NormListID,NormUniqueID",
|
|
12
|
+
"enableQueryRules": false,
|
|
13
|
+
"includeOneDriveResults": false,
|
|
14
|
+
"showBlank": true,
|
|
15
|
+
"showResultsCount": true,
|
|
16
|
+
"webPartTitle": "",
|
|
17
|
+
"enableLocalization": true,
|
|
18
|
+
"useDefaultSearchQuery": false,
|
|
19
|
+
"resultTypes@odata.type": "#Collection(String)",
|
|
20
|
+
"resultTypes": [],
|
|
21
|
+
"useExternalRefinersDisplay": false,
|
|
22
|
+
"useExternalPaginationDisplay": false,
|
|
23
|
+
"appliedRefiners@odata.type": "#Collection(String)",
|
|
24
|
+
"appliedRefiners": [],
|
|
25
|
+
"refinersConfiguration@odata.type": "#Collection(String)",
|
|
26
|
+
"refinersConfiguration": [],
|
|
27
|
+
"sortableFields@odata.type": "#Collection(String)",
|
|
28
|
+
"sortableFields": [],
|
|
29
|
+
"synonymList@odata.type": "#Collection(String)",
|
|
30
|
+
"synonymList": [],
|
|
31
|
+
"searchQueryLanguage": -1,
|
|
32
|
+
"queryModifiers@odata.type": "#Collection(String)",
|
|
33
|
+
"queryModifiers": [],
|
|
34
|
+
"refinementFilters": "",
|
|
35
|
+
"selectedLayout": 2,
|
|
36
|
+
"defaultSearchQuery": "",
|
|
37
|
+
"inlineTemplateText": "<content id=\"template\">\n\n <style>\n \n /* Insert your CSS overrides here */\n\n </style>\n\n <div class=\"template_root\">\n <span>Test</span>\n <div class=\"template_defaultCard\">\n {{#if showResultsCount}}\n <div class=\"template_resultCount\">\n <label class=\"ms-fontWeight-semibold\">{{getCountMessage @root.paging.totalItemsCount keywords}}</label>\n </div>\n {{/if}}\n <div class=\"document-card-container\">\n {{#each items as |item|}}\n <div class=\"document-card-item\">\n {{#> resultTypes item=item}}\n\n <pnp-document-card data-item=\"{{JSONstringify item}}\" data-fields-configuration=\"{{JSONstringify @root.documentCardFields}}\" data-enable-preview=\"{{@root.enablePreview}}\" data-show-file-icon=\"{{@root.showFileIcon}}\" data-is-compact=\"{{@root.isCompact}}\"></pnp-document-card>\n {{/resultTypes}}\n </div>\n {{/each}}\n </div>\n </div>\n {{#if @root.paging.showPaging}}\n <pnp-pagination \n data-total-items=\"{{@root.paging.totalItemsCount}}\" \n data-hide-first-last-pages=\"{{@root.paging.hideFirstLastPages}}\"\n data-hide-disabled=\"{{@root.paging.hideDisabled}}\"\n data-hide-navigation=\"{{@root.paging.hideNavigation}}\"\n data-range=\"{{@root.paging.pagingRange}}\" \n data-items-count-per-page=\"{{@root.paging.itemsCountPerPage}}\" \n data-current-page-number=\"{{@root.paging.currentPageNumber}}\"\n >\n </pnp-pagination>\n {{/if}}\n </div>\n</content>\n\n<content id=\"placeholder\"> \n <div class=\"placeholder_root\">\n <div class=\"template_defaultCard\">\n {{#if showResultsCount}}\n <div class=\"template_resultCount\">\n <span class=\"shimmer line\" style=\"width: 20%\"></span>\n </div>\n {{/if}}\n <div class=\"document-card-container\"> \n {{#times @root.paging.totalItemsCount}}\n <div class=\"document-card-item\">\n <pnp-document-card-shimmers data-is-compact=\"{{@root.isCompact}}\"></pnp-document-card-shimmers>\n </div>\n {{/times}}\n </div>\n </div>\n </div>\n</content>",
|
|
38
|
+
"externalTemplateUrl": "",
|
|
39
|
+
"paging": {
|
|
40
|
+
"@odata.type": "#graph.Json",
|
|
41
|
+
"itemsCountPerPage": 10,
|
|
42
|
+
"pagingRange": 5,
|
|
43
|
+
"showPaging": true,
|
|
44
|
+
"hideDisabled": true,
|
|
45
|
+
"hideFirstLastPages": false,
|
|
46
|
+
"hideNavigation": false
|
|
47
|
+
},
|
|
48
|
+
"sortList@odata.type": "#Collection(graph.Json)",
|
|
49
|
+
"sortList": [
|
|
50
|
+
{
|
|
51
|
+
"sortField": "Created",
|
|
52
|
+
"sortDirection": 1
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"sortField": "Size",
|
|
56
|
+
"sortDirection": 2
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"templateParameters": {
|
|
60
|
+
"@odata.type": "#graph.Json",
|
|
61
|
+
"showFileIcon": false,
|
|
62
|
+
"documentCardFields@odata.type": "#Collection(graph.Json)",
|
|
63
|
+
"documentCardFields": [
|
|
64
|
+
{
|
|
65
|
+
"name": "Title",
|
|
66
|
+
"field": "title",
|
|
67
|
+
"value": "Title",
|
|
68
|
+
"useHandlebarsExpr": false,
|
|
69
|
+
"supportHtml": false
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "Location",
|
|
73
|
+
"field": "location",
|
|
74
|
+
"value": "<a style=\"color:{{@themeVariant.palette.themePrimary}}\" href=\"{{SPSiteUrl}}\">{{SiteTitle}}</a>",
|
|
75
|
+
"useHandlebarsExpr": true,
|
|
76
|
+
"supportHtml": true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "Tags",
|
|
80
|
+
"field": "tags",
|
|
81
|
+
"value": "{{#if owstaxidmetadataalltagsinfo}}<i class='ms-Icon ms-Icon--Tag' aria-hidden='true'></i> {{#each (split owstaxidmetadataalltagsinfo ',') as |tag| }}<a class=\"ms-Link\" href=\"#owstaxidmetadataalltagsinfo:'{{trim tag}}'\">{{tag}}</a>{{/each}}{{/if}}",
|
|
82
|
+
"useHandlebarsExpr": true,
|
|
83
|
+
"supportHtml": true
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "Preview Image",
|
|
87
|
+
"field": "previewImage",
|
|
88
|
+
"value": "{{{getPreviewSrc item}}}",
|
|
89
|
+
"useHandlebarsExpr": true,
|
|
90
|
+
"supportHtml": false
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "Preview URL",
|
|
94
|
+
"field": "previewUrl",
|
|
95
|
+
"value": "{{#eq contentclass 'STS_ListItem_851'}}{{{DefaultEncodingURL}}}{{else}}{{#eq FileType 'pdf'}}{{#contains Path '-my.sharepoint'}}{{{ServerRedirectedEmbedURL}}}{{else}}{{{Path}}}{{/contains}}{{else}}{{{ServerRedirectedEmbedURL}}}{{/eq}}{{/eq}} ",
|
|
96
|
+
"useHandlebarsExpr": true,
|
|
97
|
+
"supportHtml": false
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "Date",
|
|
101
|
+
"field": "date",
|
|
102
|
+
"value": "{{getDate item.Created 'LL'}}",
|
|
103
|
+
"useHandlebarsExpr": true,
|
|
104
|
+
"supportHtml": false
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "URL",
|
|
108
|
+
"field": "href",
|
|
109
|
+
"value": "{{getUrl item}}",
|
|
110
|
+
"useHandlebarsExpr": true,
|
|
111
|
+
"supportHtml": false
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "Author",
|
|
115
|
+
"field": "author",
|
|
116
|
+
"value": "Author",
|
|
117
|
+
"useHandlebarsExpr": false,
|
|
118
|
+
"supportHtml": false
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Profile Image",
|
|
122
|
+
"field": "profileImage",
|
|
123
|
+
"value": "{{#with (split AuthorOWSUSER '|')}}/_layouts/15/userphoto.aspx?size=L&username={{[0]}}{{/with}}",
|
|
124
|
+
"useHandlebarsExpr": true,
|
|
125
|
+
"supportHtml": false
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "IconSrc",
|
|
129
|
+
"field": "iconSrc",
|
|
130
|
+
"value": "{{IconSrc}}",
|
|
131
|
+
"useHandlebarsExpr": true,
|
|
132
|
+
"supportHtml": false
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "IconExt",
|
|
136
|
+
"field": "iconExt",
|
|
137
|
+
"value": "{{IconExt}}",
|
|
138
|
+
"useHandlebarsExpr": true,
|
|
139
|
+
"supportHtml": false
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"name": "File Extension",
|
|
143
|
+
"field": "fileExtension",
|
|
144
|
+
"value": "FileType",
|
|
145
|
+
"useHandlebarsExpr": false,
|
|
146
|
+
"supportHtml": false
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"detailsListColumns@odata.type": "#Collection(graph.Json)",
|
|
150
|
+
"detailsListColumns": [
|
|
151
|
+
{
|
|
152
|
+
"name": "Title",
|
|
153
|
+
"value": "Title",
|
|
154
|
+
"useHandlebarsExpr": false,
|
|
155
|
+
"minWidth": "80",
|
|
156
|
+
"maxWidth": "300",
|
|
157
|
+
"enableSorting": false,
|
|
158
|
+
"isMultiline": false,
|
|
159
|
+
"isResizable": true,
|
|
160
|
+
"isResultItemLink": true,
|
|
161
|
+
"sortIdx": 1
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "Created",
|
|
165
|
+
"value": "{{getDate Created 'LL'}}",
|
|
166
|
+
"useHandlebarsExpr": true,
|
|
167
|
+
"minWidth": "80",
|
|
168
|
+
"maxWidth": "120",
|
|
169
|
+
"enableSorting": false,
|
|
170
|
+
"isMultiline": false,
|
|
171
|
+
"isResizable": false,
|
|
172
|
+
"isResultItemLink": false,
|
|
173
|
+
"sortIdx": 2
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "Summary",
|
|
177
|
+
"value": "{{getSummary HitHighlightedSummary}}",
|
|
178
|
+
"useHandlebarsExpr": true,
|
|
179
|
+
"minWidth": "80",
|
|
180
|
+
"maxWidth": "300",
|
|
181
|
+
"enableSorting": false,
|
|
182
|
+
"isMultiline": true,
|
|
183
|
+
"isResizable": false,
|
|
184
|
+
"isResultItemLink": false,
|
|
185
|
+
"sortIdx": 3
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"uniqueId": "9c4eb969-17ac-4bf0-928e-7eb916688378",
|
|
189
|
+
"name": "Author",
|
|
190
|
+
"value": "Author",
|
|
191
|
+
"minWidth": "50",
|
|
192
|
+
"maxWidth": "310",
|
|
193
|
+
"enableSorting": true
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var clientId = import.meta.env.VITE_FRONTEND_CLIENT_ID;
|
|
199
|
+
var authService = new Msal2AuthenticationService({ clientId: clientId }, false);
|
|
200
|
+
var _a = React.useState(), site = _a[0], setSite = _a[1];
|
|
201
|
+
return (React.createElement(AuthenticationContextProvider, { authProvider: authService },
|
|
202
|
+
React.createElement(GraphContextProvider, null,
|
|
203
|
+
React.createElement(SPContextProvider, { siteUrl: import.meta.env.VITE_SITE_URL },
|
|
204
|
+
React.createElement(React.Fragment, null,
|
|
205
|
+
React.createElement(PeoplePicker, { key: "people-picker", label: "People picker", description: "Pick some people here" }),
|
|
206
|
+
React.createElement(TeamPicker, { key: "team-picker", label: "Team picker", description: "Pick a team here" }),
|
|
207
|
+
React.createElement(DrivePicker, { key: "drive-picker", label: "Drive picker", description: "Pick a drive here" }),
|
|
208
|
+
React.createElement(SitePicker, { onEntitySelected: function (site) { return setSite(site[0]); }, label: "Site picker", description: "Pick a site " }),
|
|
209
|
+
site && React.createElement(ListPickerPicker, { siteId: site.id, label: "List picker", description: "Pick a list from ".concat(site.displayName) }),
|
|
210
|
+
React.createElement(GetSiteTemplateContext, null))))));
|
|
211
|
+
}
|
|
212
|
+
export default App;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useGraph, useSP } from "../context";
|
|
3
|
+
export function Test(props) {
|
|
4
|
+
var graphClient = useGraph().graphClient;
|
|
5
|
+
var _a = useSP(), spClient = _a.spClient, siteUrl = _a.siteUrl;
|
|
6
|
+
var _b = React.useState(true), loading = _b[0], setLoading = _b[1];
|
|
7
|
+
var _c = React.useState(undefined), user = _c[0], setUser = _c[1];
|
|
8
|
+
var _d = React.useState(undefined), web = _d[0], setWeb = _d[1];
|
|
9
|
+
React.useEffect(function () {
|
|
10
|
+
if (graphClient) {
|
|
11
|
+
graphClient.get("https://graph.microsoft.com/v1.0/me").then(function (resp) {
|
|
12
|
+
resp.json().then(function (response) {
|
|
13
|
+
setUser(response);
|
|
14
|
+
setLoading(false);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (spClient) {
|
|
19
|
+
spClient.get("".concat(siteUrl, "/_api/web"), {
|
|
20
|
+
headers: {
|
|
21
|
+
"Accept": "application/json;odata=nometadata"
|
|
22
|
+
}
|
|
23
|
+
}).then(function (resp) {
|
|
24
|
+
resp.json().then(function (response) {
|
|
25
|
+
setWeb(response);
|
|
26
|
+
setLoading(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, [graphClient]);
|
|
31
|
+
if (loading) {
|
|
32
|
+
return React.createElement("div", null, "Loading...");
|
|
33
|
+
}
|
|
34
|
+
return React.createElement("div", null,
|
|
35
|
+
React.createElement("div", null, user === null || user === void 0 ? void 0 : user.displayName),
|
|
36
|
+
React.createElement("div", null, web === null || web === void 0 ? void 0 : web.Title));
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IHttpClient, IUser } from "mgwdev-m365-helpers";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { PersonaProps } from "@fluentui/react-components";
|
|
4
|
+
export interface IGraphPersonaProps extends PersonaProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
user?: IUser;
|
|
7
|
+
showPresence?: boolean;
|
|
8
|
+
graphClient?: IHttpClient;
|
|
9
|
+
}
|
|
10
|
+
export declare function GraphPersona(props: IGraphPersonaProps): React.JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import * as React from "react";
|
|
49
|
+
import { Persona, Spinner } from "@fluentui/react-components";
|
|
50
|
+
import { PersonaService } from "../../services/PersonaService";
|
|
51
|
+
import { useGraph } from "../../context";
|
|
52
|
+
export function GraphPersona(props) {
|
|
53
|
+
var _this = this;
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
|
+
var id = props.id;
|
|
56
|
+
var graphClient = props.graphClient;
|
|
57
|
+
if (!graphClient) {
|
|
58
|
+
graphClient = (useGraph()).graphClient;
|
|
59
|
+
}
|
|
60
|
+
var getPresence = function (presenceString) {
|
|
61
|
+
switch (presenceString) {
|
|
62
|
+
case "":
|
|
63
|
+
return "offline";
|
|
64
|
+
case "Available":
|
|
65
|
+
return "available";
|
|
66
|
+
case "Busy":
|
|
67
|
+
return "busy";
|
|
68
|
+
case "Away":
|
|
69
|
+
return "away";
|
|
70
|
+
case "DoNotDisturb":
|
|
71
|
+
return "do-not-disturb";
|
|
72
|
+
case "Offline":
|
|
73
|
+
return "offline";
|
|
74
|
+
case "PresenceUnknown":
|
|
75
|
+
return "unknown";
|
|
76
|
+
case "OutOfOffice":
|
|
77
|
+
return "out-of-office";
|
|
78
|
+
case "Blocked":
|
|
79
|
+
return "blocked";
|
|
80
|
+
case "BeRightBack":
|
|
81
|
+
return "away";
|
|
82
|
+
case "BusyIdle":
|
|
83
|
+
return "busy";
|
|
84
|
+
case "AvailableIdle":
|
|
85
|
+
return "available";
|
|
86
|
+
default:
|
|
87
|
+
return presenceString === null || presenceString === void 0 ? void 0 : presenceString.toLowerCase();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var personaService = React.useRef(new PersonaService(graphClient, props.showPresence));
|
|
91
|
+
var _f = React.useState(!props.user), loading = _f[0], setLoading = _f[1];
|
|
92
|
+
var _g = React.useState(props.user), user = _g[0], setUser = _g[1];
|
|
93
|
+
var getUserInfo = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
94
|
+
var userResult;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0: return [4 /*yield*/, personaService.current.getUser(id)];
|
|
98
|
+
case 1:
|
|
99
|
+
userResult = _a.sent();
|
|
100
|
+
setUser(__assign(__assign({}, props.user), userResult));
|
|
101
|
+
setLoading(false);
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
106
|
+
React.useEffect(function () {
|
|
107
|
+
if (!props.user) {
|
|
108
|
+
getUserInfo();
|
|
109
|
+
}
|
|
110
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
}, [id]);
|
|
112
|
+
if (loading) {
|
|
113
|
+
return React.createElement(Spinner, null);
|
|
114
|
+
}
|
|
115
|
+
var primaryText = (user === null || user === void 0 ? void 0 : user.displayName) || props.name || props.title || props.id;
|
|
116
|
+
return (React.createElement(Persona, __assign({ primaryText: primaryText, secondaryText: user === null || user === void 0 ? void 0 : user.jobTitle, avatar: {
|
|
117
|
+
image: { src: user === null || user === void 0 ? void 0 : user.photo },
|
|
118
|
+
initials: ((_a = user === null || user === void 0 ? void 0 : user.displayName) === null || _a === void 0 ? void 0 : _a.split(" ").map(function (x) { return x[0]; }).join("")) || ((_b = props.name) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (x) { return x[0]; }).join("")),
|
|
119
|
+
}, presence: props.showPresence
|
|
120
|
+
? {
|
|
121
|
+
status: getPresence((_c = user === null || user === void 0 ? void 0 : user.presence) === null || _c === void 0 ? void 0 : _c.availability),
|
|
122
|
+
outOfOffice: (_e = (_d = user === null || user === void 0 ? void 0 : user.presence) === null || _d === void 0 ? void 0 : _d.outOfOfficeSettings) === null || _e === void 0 ? void 0 : _e.isOutOfOffice
|
|
123
|
+
}
|
|
124
|
+
: undefined }, props)));
|
|
125
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IEntityWithIdAndDisplayName } from "../../../model/IEntityWithIdAndDisplayName";
|
|
3
|
+
export interface IAbstractGraphEntityPickerProps<T> {
|
|
4
|
+
onDataRequested: (searchText: string) => Promise<T[]>;
|
|
5
|
+
value?: T[];
|
|
6
|
+
label?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
multiSelect?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
additionalKey?: string;
|
|
11
|
+
onEntitySelected?: (entities: T[]) => void;
|
|
12
|
+
size?: "small" | "medium" | "large";
|
|
13
|
+
onSuggestionRendering?: (entity: T) => React.ReactNode;
|
|
14
|
+
renderOverride?: (entities: T[], isLoading: boolean, loadData: (query?: string) => Promise<void>) => JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export declare function AbstractGraphEntityPicker<T extends IEntityWithIdAndDisplayName>(props: IAbstractGraphEntityPickerProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { Combobox, Field, ProgressBar, Option } from "@fluentui/react-components";
|
|
47
|
+
import { DebounceHandler } from "mgwdev-m365-helpers/lib/utils/DebounceHandler";
|
|
48
|
+
import * as React from "react";
|
|
49
|
+
export function AbstractGraphEntityPicker(props) {
|
|
50
|
+
var _this = this;
|
|
51
|
+
var _a = React.useState(props.value || []), entities = _a[0], setEntities = _a[1];
|
|
52
|
+
var _b = React.useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
53
|
+
var _c = React.useState(""), inputValue = _c[0], setInputValue = _c[1];
|
|
54
|
+
var _d = React.useState(props.value || []), selectedEntities = _d[0], setSelectedEntities = _d[1];
|
|
55
|
+
var loadEntities = function (searchText) {
|
|
56
|
+
return DebounceHandler.debounce("entityPicker-".concat(props.additionalKey), function () { return __awaiter(_this, void 0, void 0, function () {
|
|
57
|
+
var queriedEntities, e_1;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
setIsLoading(true);
|
|
62
|
+
_a.label = 1;
|
|
63
|
+
case 1:
|
|
64
|
+
_a.trys.push([1, 3, , 4]);
|
|
65
|
+
return [4 /*yield*/, props.onDataRequested(searchText)];
|
|
66
|
+
case 2:
|
|
67
|
+
queriedEntities = _a.sent();
|
|
68
|
+
//get distinct entities
|
|
69
|
+
setEntities(__spreadArray(__spreadArray([], queriedEntities, true), selectedEntities, true).reduce(function (acc, current) {
|
|
70
|
+
var x = acc.find(function (item) { return item.id === current.id; });
|
|
71
|
+
if (!x) {
|
|
72
|
+
return acc.concat([current]);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return acc;
|
|
76
|
+
}
|
|
77
|
+
}, []));
|
|
78
|
+
setIsLoading(false);
|
|
79
|
+
return [3 /*break*/, 4];
|
|
80
|
+
case 3:
|
|
81
|
+
e_1 = _a.sent();
|
|
82
|
+
console.error(e_1);
|
|
83
|
+
setIsLoading(false);
|
|
84
|
+
return [3 /*break*/, 4];
|
|
85
|
+
case 4: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); }, 500);
|
|
89
|
+
};
|
|
90
|
+
React.useEffect(function () {
|
|
91
|
+
loadEntities(inputValue);
|
|
92
|
+
}, [inputValue]);
|
|
93
|
+
if (props.renderOverride) {
|
|
94
|
+
return props.renderOverride(entities, isLoading, loadEntities);
|
|
95
|
+
}
|
|
96
|
+
return React.createElement(Field, { label: props.label, hint: props.description },
|
|
97
|
+
React.createElement(Combobox, { value: inputValue, multiselect: props.multiSelect, freeform: true, onChange: function (e) {
|
|
98
|
+
setInputValue(e.target.value);
|
|
99
|
+
}, size: props.size, disabled: props.disabled, onOptionSelect: function (e, data) {
|
|
100
|
+
var newSelected = [];
|
|
101
|
+
var selectedEntity = entities.find(function (x) { return x.id === data.optionValue; });
|
|
102
|
+
if (selectedEntities.some(function (x) { return x.id === data.optionValue; })) {
|
|
103
|
+
newSelected = selectedEntities.filter(function (x) { return x.id !== data.optionValue; });
|
|
104
|
+
}
|
|
105
|
+
else if (props.multiSelect) {
|
|
106
|
+
newSelected = __spreadArray(__spreadArray([], selectedEntities, true), [selectedEntity], false);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
newSelected = [selectedEntity];
|
|
110
|
+
}
|
|
111
|
+
newSelected = newSelected.filter(function (x) { return !!x; });
|
|
112
|
+
props.onEntitySelected && props.onEntitySelected(newSelected);
|
|
113
|
+
setSelectedEntities(newSelected);
|
|
114
|
+
setInputValue(newSelected.map(function (x) { return x.displayName; }).join(", "));
|
|
115
|
+
}, defaultSelectedOptions: selectedEntities.map(function (x) { return x.id; }) }, entities.map(function (x) { return React.createElement(Option, { key: encodeURIComponent(x.id), text: x.displayName, value: x.id }, props.onSuggestionRendering ? props.onSuggestionRendering(x) : x.displayName); })),
|
|
116
|
+
isLoading && React.createElement(ProgressBar, null));
|
|
117
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IEntityWithIdAndDisplayName } from "../../../model/IEntityWithIdAndDisplayName";
|
|
3
|
+
import { IAbstractGraphEntityPickerProps } from "./AbstractGraphEntityPicker";
|
|
4
|
+
import { IHttpClient } from "mgwdev-m365-helpers";
|
|
5
|
+
export interface IChannelPickerProps extends Partial<IAbstractGraphEntityPickerProps<IEntityWithIdAndDisplayName>> {
|
|
6
|
+
teamId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function ChannelPicker(props: IChannelPickerProps): React.JSX.Element;
|
|
9
|
+
export declare function ChannelPickerStandalone(props: IChannelPickerProps & {
|
|
10
|
+
graphClient: IHttpClient;
|
|
11
|
+
}): React.JSX.Element;
|