mgwdev-m365-components 0.0.8 → 1.0.9-spfx-1.22

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.
@@ -1,4 +1,2 @@
1
1
  import * as React from "react";
2
- export interface ITestProps {
3
- }
4
- export declare function Test(props: ITestProps): React.JSX.Element;
2
+ export declare function Test(): React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import { IGraphSearchResult } from "../../model";
2
+ import { IDocumentSearchResult, IGraphSearchResult } from "../../model";
3
3
  export interface IM365CopilotSearchProps<T> {
4
- onResultRendering?: (result: IGraphSearchResult<T>) => any;
4
+ onResultRendering?: (result: IGraphSearchResult<T>) => JSX.Element;
5
5
  dataProviderProps?: {
6
6
  pageSize?: number;
7
7
  initialQuery?: string;
@@ -12,4 +12,4 @@ export interface IM365CopilotSearchProps<T> {
12
12
  onSearch: (query: string) => void;
13
13
  }) => JSX.Element;
14
14
  }
15
- export declare const M365CopilotSearch: <T>(props: IM365CopilotSearchProps<T>) => React.JSX.Element;
15
+ export declare const M365CopilotSearch: <T extends IDocumentSearchResult>(props: IM365CopilotSearchProps<T>) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { IAggregationRequest } from "mgwdev-m365-helpers";
3
- import { IGraphSearchResult } from "../../model";
3
+ import { IDocumentSearchResult, IGraphSearchResult } from "../../model";
4
4
  export interface IM365SearchProps<T> {
5
- onResultRendering?: (result: IGraphSearchResult<T>) => any;
5
+ onResultRendering?: (result: IGraphSearchResult<T>) => JSX.Element;
6
6
  dataProviderProps?: {
7
7
  pageSize?: number;
8
8
  initialQuery?: string;
@@ -15,4 +15,4 @@ export interface IM365SearchProps<T> {
15
15
  onSearch: (query: string) => void;
16
16
  }) => JSX.Element;
17
17
  }
18
- export declare const M365Search: <T>(props: IM365SearchProps<T>) => React.JSX.Element;
18
+ export declare const M365Search: <T extends IDocumentSearchResult>(props: IM365SearchProps<T>) => React.JSX.Element;
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  export interface IAuthenticationContextProps {
4
4
  authProvider: IAuthenticationService;
5
5
  }
6
- export interface IAuthenticationContextProviderProps extends React.PropsWithChildren<{}> {
6
+ export interface IAuthenticationContextProviderProps extends React.PropsWithChildren<object> {
7
7
  authProvider?: IAuthenticationService;
8
8
  }
9
9
  export declare const AuthenticationContext: React.Context<IAuthenticationContextProps>;
@@ -4,7 +4,7 @@ export interface IDataverseContextProps {
4
4
  dataverseClient: IHttpClient;
5
5
  dataverseResource?: string;
6
6
  }
7
- export interface IDataverseContextProviderProps extends React.PropsWithChildren<{}> {
7
+ export interface IDataverseContextProviderProps extends React.PropsWithChildren<object> {
8
8
  dataverseResource: string;
9
9
  dataverseClient?: IHttpClient;
10
10
  autoBatch?: boolean;
@@ -3,7 +3,7 @@ import { IHttpClient } from "mgwdev-m365-helpers";
3
3
  export interface IGraphContextProps {
4
4
  graphClient: IHttpClient;
5
5
  }
6
- export interface IGraphContextProviderProps extends React.PropsWithChildren<{}> {
6
+ export interface IGraphContextProviderProps extends React.PropsWithChildren<object> {
7
7
  graphClient?: IHttpClient;
8
8
  }
9
9
  export declare const GraphContext: React.Context<IGraphContextProps>;
@@ -4,7 +4,7 @@ export interface ISPContextProps {
4
4
  spClient: IHttpClient;
5
5
  siteUrl: string;
6
6
  }
7
- export interface ISPContextProviderProps extends React.PropsWithChildren<{}> {
7
+ export interface ISPContextProviderProps extends React.PropsWithChildren<object> {
8
8
  spClient?: IHttpClient;
9
9
  siteUrl: string;
10
10
  }
@@ -656,9 +656,12 @@ const pc = /* @__PURE__ */ hc(E), mc = /* @__PURE__ */ dc({
656
656
  throw new Error("No auth provider available");
657
657
  }
658
658
  }
659
- }), _n = () => g.useContext(Ya), $1 = (e) => /* @__PURE__ */ E.jsx(Ya.Provider, { value: {
660
- authProvider: e.authProvider
661
- }, children: e.children });
659
+ }), _n = () => g.useContext(Ya), $1 = (e) => {
660
+ const t = g.useMemo(() => ({
661
+ authProvider: e.authProvider
662
+ }), [e.authProvider]);
663
+ return /* @__PURE__ */ E.jsx(Ya.Provider, { value: t, children: e.children });
664
+ };
662
665
  var Qr = (
663
666
  /** @class */
664
667
  function() {
@@ -2985,11 +2988,11 @@ const rs = g.createContext({
2985
2988
  if (t)
2986
2989
  return new xc(new Sn(t, new or()));
2987
2990
  }, [o, i] = g.useState(r());
2988
- return g.useEffect(() => {
2991
+ g.useEffect(() => {
2989
2992
  i(r());
2990
- }, [e.graphClient, t]), o && /* @__PURE__ */ E.jsx(rs.Provider, { value: {
2991
- graphClient: o
2992
- }, children: e.children });
2993
+ }, [e.graphClient, t]);
2994
+ const n = g.useMemo(() => ({ graphClient: o }), [o]);
2995
+ return o && /* @__PURE__ */ E.jsx(rs.Provider, { value: n, children: e.children });
2993
2996
  }, os = g.createContext({
2994
2997
  spClient: new or(),
2995
2998
  siteUrl: ""
@@ -2998,16 +3001,18 @@ const rs = g.createContext({
2998
3001
  if (e.spClient)
2999
3002
  return e.spClient;
3000
3003
  if (t) {
3001
- let n = new Sn(t, new or());
3002
- return n.resourceUri = new URL(e.siteUrl).origin, n;
3004
+ const s = new Sn(t, new or());
3005
+ return s.resourceUri = new URL(e.siteUrl).origin, s;
3003
3006
  }
3004
3007
  }, [o, i] = g.useState(r());
3005
- return g.useEffect(() => {
3008
+ g.useEffect(() => {
3006
3009
  i(r());
3007
- }, [e.spClient, t]), o && /* @__PURE__ */ E.jsx(os.Provider, { value: {
3010
+ }, [e.spClient, t]);
3011
+ const n = g.useMemo(() => ({
3008
3012
  spClient: o,
3009
3013
  siteUrl: e.siteUrl
3010
- }, children: e.children });
3014
+ }), [e.siteUrl, o]);
3015
+ return o && /* @__PURE__ */ E.jsx(os.Provider, { value: n, children: e.children });
3011
3016
  }, ns = g.createContext({
3012
3017
  dataverseClient: new or()
3013
3018
  }), G1 = () => g.useContext(ns), X1 = (e) => {
@@ -3015,16 +3020,18 @@ const rs = g.createContext({
3015
3020
  if (e.dataverseClient)
3016
3021
  return e.dataverseClient;
3017
3022
  if (t) {
3018
- let n = new Sn(t, new or());
3019
- return n.resourceUri = e.dataverseResource, e.autoBatch && (n = new Sc(n, e.dataverseResource, e.apiPath, 500)), n;
3023
+ let s = new Sn(t, new or());
3024
+ return s.resourceUri = e.dataverseResource, e.autoBatch && (s = new Sc(s, e.dataverseResource, e.apiPath, 500)), s;
3020
3025
  }
3021
3026
  }, [o, i] = g.useState(r());
3022
- return g.useEffect(() => {
3027
+ g.useEffect(() => {
3023
3028
  i(r());
3024
- }, [e.dataverseClient, t]), o && /* @__PURE__ */ E.jsx(ns.Provider, { value: {
3029
+ }, [e.dataverseClient, t]);
3030
+ const n = g.useMemo(() => ({
3025
3031
  dataverseClient: o,
3026
3032
  dataverseResource: e.dataverseResource
3027
- }, children: e.children });
3033
+ }), [e.dataverseResource, o]);
3034
+ return o && /* @__PURE__ */ E.jsx(ns.Provider, { value: n, children: e.children });
3028
3035
  }, qc = ["Top", "Right", "Bottom", "Left"];
3029
3036
  function Nr(e, t, ...r) {
3030
3037
  const [o, i = o, n = o, s = i] = r, l = [o, i, n, s], u = {};
@@ -15609,7 +15616,7 @@ const N1 = jn({
15609
15616
  var d;
15610
15617
  const { graphClient: t } = nt(), r = E1(), o = g.useMemo(() => {
15611
15618
  var m, w, b, y, S, x, P;
15612
- var h = new ts(
15619
+ const h = new ts(
15613
15620
  t,
15614
15621
  [((m = e.dataProviderProps) == null ? void 0 : m.entityType) ?? "listItem"],
15615
15622
  ((w = e.dataProviderProps) == null ? void 0 : w.selectFields) || Yl
@@ -15636,7 +15643,7 @@ const N1 = jn({
15636
15643
  i && /* @__PURE__ */ E.jsx(xo, { label: "Loading..." }),
15637
15644
  !i && c && /* @__PURE__ */ E.jsxs("div", { children: [
15638
15645
  "Error: ",
15639
- c
15646
+ c.message
15640
15647
  ] })
15641
15648
  ] }),
15642
15649
  /* @__PURE__ */ E.jsx("div", { className: r.searchResults, children: u.map((h, m) => /* @__PURE__ */ E.jsx("div", { children: e != null && e.onResultRendering ? e.onResultRendering(h) : /* @__PURE__ */ E.jsx(Ql, { document: h }) }, m)) })
@@ -15654,13 +15661,12 @@ const N1 = jn({
15654
15661
  var d;
15655
15662
  const { graphClient: t } = nt(), r = j1(), o = g.useMemo(() => {
15656
15663
  var m, w;
15657
- var h = new Ec(
15664
+ return new Ec(
15658
15665
  t,
15659
15666
  "sharePoint",
15660
15667
  ((m = e.dataProviderProps) == null ? void 0 : m.selectFields) || Yl,
15661
15668
  (w = e.dataProviderProps) == null ? void 0 : w.queryTemplate
15662
15669
  );
15663
- return h;
15664
15670
  }, [t, e.dataProviderProps]), [i, n] = g.useState(!0), [s, l] = g.useState(((d = e.dataProviderProps) == null ? void 0 : d.initialQuery) ?? ""), [u, a] = g.useState([]), [c, f] = g.useState(void 0);
15665
15671
  g.useEffect(() => {
15666
15672
  es.debounce("copilot-search", async () => {
@@ -15686,10 +15692,13 @@ const N1 = jn({
15686
15692
  i && /* @__PURE__ */ E.jsx(xo, { label: "Loading..." }),
15687
15693
  !i && c && /* @__PURE__ */ E.jsxs("div", { children: [
15688
15694
  "Error: ",
15689
- c
15695
+ c.message
15690
15696
  ] })
15691
15697
  ] }),
15692
- /* @__PURE__ */ E.jsx("div", { className: r.searchResults, children: u.map((h, m) => /* @__PURE__ */ E.jsx("div", { children: e != null && e.onResultRendering ? e.onResultRendering(h) : /* @__PURE__ */ E.jsx(Ql, { document: {
15698
+ /* @__PURE__ */ E.jsx("div", { className: r.searchResults, children: u.map((h, m) => /* @__PURE__ */ E.jsx("div", { children: e != null && e.onResultRendering ? e.onResultRendering({
15699
+ fields: h.resourceMetadata,
15700
+ ...h
15701
+ }) : /* @__PURE__ */ E.jsx(Ql, { document: {
15693
15702
  fields: h.resourceMetadata,
15694
15703
  ...h
15695
15704
  } }) }, m)) })
@@ -15712,7 +15721,8 @@ class Jl {
15712
15721
  return null;
15713
15722
  o = (await u.json()).id;
15714
15723
  }
15715
- let i = this.storageService.get(this.key + t), n = i == null ? void 0 : i.data;
15724
+ const i = this.storageService.get(this.key + t);
15725
+ let n = i == null ? void 0 : i.data;
15716
15726
  const s = o ? `/users/${o}` : "/me";
15717
15727
  if (!n || i.expiration < (/* @__PURE__ */ new Date()).getTime()) {
15718
15728
  const [l, u, a] = await Promise.all(
@@ -15752,9 +15762,7 @@ q1([
15752
15762
  ], Jl.prototype, "getUser", 1);
15753
15763
  function ec(e) {
15754
15764
  var f, v, d, h, m;
15755
- const { id: t } = e;
15756
- let r = e.graphClient;
15757
- const o = (w) => {
15765
+ const { id: t } = e, r = e.graphClient, o = (w) => {
15758
15766
  switch (w) {
15759
15767
  case "":
15760
15768
  return "offline";
@@ -15869,7 +15877,7 @@ function A1(e) {
15869
15877
  g.useEffect(() => {
15870
15878
  t();
15871
15879
  }, [e.teamId]);
15872
- const r = async (o) => await t();
15880
+ const r = async () => await t();
15873
15881
  return /* @__PURE__ */ E.jsx(Fr, { additionalKey: `team-${e.teamId}-channels`, ...e, onDataRequested: r });
15874
15882
  }
15875
15883
  function J1(e) {
@@ -15924,7 +15932,7 @@ function tc(e) {
15924
15932
  e.permissionCheck().then((n) => {
15925
15933
  r(n);
15926
15934
  }).finally(() => i(!1));
15927
- }, []), o && e.placeholder ? /* @__PURE__ */ E.jsx(E.Fragment, { children: e.placeholder }) : t ? /* @__PURE__ */ E.jsx(E.Fragment, { children: e.children }) : /* @__PURE__ */ E.jsx(E.Fragment, {});
15935
+ }, [e.permissionCheck]), o && e.placeholder ? /* @__PURE__ */ E.jsx(E.Fragment, { children: e.placeholder }) : t ? /* @__PURE__ */ E.jsx(E.Fragment, { children: e.children }) : /* @__PURE__ */ E.jsx(E.Fragment, {});
15928
15936
  }
15929
15937
  function o0(e) {
15930
15938
  const { spClient: t, siteUrl: r } = Fc();
@@ -15932,15 +15940,13 @@ function o0(e) {
15932
15940
  }
15933
15941
  function L1(e) {
15934
15942
  return /* @__PURE__ */ E.jsx(tc, { placeholder: e.placeholder, permissionCheck: async () => {
15935
- var t = `${e.siteUrl}/_api/web/EffectiveBasePermissions`, r = await e.spClient.get(t, {
15943
+ const t = `${e.siteUrl}/_api/web/EffectiveBasePermissions`, o = await (await e.spClient.get(t, {
15936
15944
  headers: {
15937
15945
  accept: "application/json"
15938
15946
  }
15939
- }), o = await r.json(), i = [];
15940
- for (var n in Ut) {
15941
- var s = Rc.hasPermission(o, Ut[n]);
15942
- s && i.push(n);
15943
- }
15947
+ })).json(), i = [];
15948
+ for (const n in Ut)
15949
+ Rc.hasPermission(o, Ut[n]) && i.push(n);
15944
15950
  return i.indexOf(e.role) >= 0;
15945
15951
  }, children: e.children }, `${e.role}-${e.siteUrl}`);
15946
15952
  }