@apvee/spfx-react-toolkit 1.2.0 → 1.3.0
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/README.md +52 -7217
- package/lib/core/context.internal.d.ts +6 -1
- package/lib/core/context.internal.d.ts.map +1 -1
- package/lib/core/context.internal.js +6 -1
- package/lib/core/context.internal.js.map +1 -1
- package/lib/core/index.d.ts +21 -0
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +21 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/provider-application-customizer.d.ts.map +1 -1
- package/lib/core/provider-application-customizer.js.map +1 -1
- package/lib/core/provider-field-customizer.d.ts.map +1 -1
- package/lib/core/provider-field-customizer.js.map +1 -1
- package/lib/core/provider-listview-commandset.d.ts.map +1 -1
- package/lib/core/provider-listview-commandset.js.map +1 -1
- package/lib/core/provider-webpart.d.ts.map +1 -1
- package/lib/core/provider-webpart.js.map +1 -1
- package/lib/core/types.d.ts +2 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/extensions/spFxReactToolkitTest/SpFxReactToolkitTestApplicationCustomizer.d.ts +14 -0
- package/lib/extensions/spFxReactToolkitTest/SpFxReactToolkitTestApplicationCustomizer.d.ts.map +1 -0
- package/lib/extensions/spFxReactToolkitTest/SpFxReactToolkitTestApplicationCustomizer.js +41 -0
- package/lib/extensions/spFxReactToolkitTest/SpFxReactToolkitTestApplicationCustomizer.js.map +1 -0
- package/lib/extensions/spFxReactToolkitTest/SpFxReactToolkitTestApplicationCustomizer.manifest.json +17 -0
- package/lib/extensions/spFxReactToolkitTest/loc/en-us.js +5 -0
- package/lib/hooks/index.d.ts +31 -0
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/index.js +31 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useAsyncInvoke.internal.d.ts +58 -0
- package/lib/hooks/useAsyncInvoke.internal.d.ts.map +1 -0
- package/lib/hooks/useAsyncInvoke.internal.js +118 -0
- package/lib/hooks/useAsyncInvoke.internal.js.map +1 -0
- package/lib/hooks/useSPFxAadHttpClient.d.ts +46 -0
- package/lib/hooks/useSPFxAadHttpClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxAadHttpClient.js +55 -80
- package/lib/hooks/useSPFxAadHttpClient.js.map +1 -1
- package/lib/hooks/useSPFxContainerInfo.d.ts +2 -0
- package/lib/hooks/useSPFxContainerInfo.d.ts.map +1 -1
- package/lib/hooks/useSPFxContainerInfo.js +2 -0
- package/lib/hooks/useSPFxContainerInfo.js.map +1 -1
- package/lib/hooks/useSPFxDisplayMode.d.ts +4 -0
- package/lib/hooks/useSPFxDisplayMode.d.ts.map +1 -1
- package/lib/hooks/useSPFxDisplayMode.js +4 -0
- package/lib/hooks/useSPFxDisplayMode.js.map +1 -1
- package/lib/hooks/useSPFxHttpClient.d.ts +22 -2
- package/lib/hooks/useSPFxHttpClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxHttpClient.js +19 -76
- package/lib/hooks/useSPFxHttpClient.js.map +1 -1
- package/lib/hooks/useSPFxMSGraphClient.d.ts +50 -3
- package/lib/hooks/useSPFxMSGraphClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxMSGraphClient.js +60 -77
- package/lib/hooks/useSPFxMSGraphClient.js.map +1 -1
- package/lib/hooks/useSPFxOneDriveAppData.d.ts +0 -1
- package/lib/hooks/useSPFxOneDriveAppData.d.ts.map +1 -1
- package/lib/hooks/useSPFxOneDriveAppData.js +352 -101
- package/lib/hooks/useSPFxOneDriveAppData.js.map +1 -1
- package/lib/hooks/useSPFxPermissions.d.ts +15 -3
- package/lib/hooks/useSPFxPermissions.d.ts.map +1 -1
- package/lib/hooks/useSPFxPermissions.js.map +1 -1
- package/lib/hooks/useSPFxPnPContext.d.ts +4 -0
- package/lib/hooks/useSPFxPnPContext.d.ts.map +1 -1
- package/lib/hooks/useSPFxPnPContext.js +4 -0
- package/lib/hooks/useSPFxPnPContext.js.map +1 -1
- package/lib/hooks/useSPFxPnPSearch.d.ts.map +1 -1
- package/lib/hooks/useSPFxPnPSearch.js +61 -48
- package/lib/hooks/useSPFxPnPSearch.js.map +1 -1
- package/lib/hooks/useSPFxSPHttpClient.d.ts +18 -2
- package/lib/hooks/useSPFxSPHttpClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxSPHttpClient.js +15 -75
- package/lib/hooks/useSPFxSPHttpClient.js.map +1 -1
- package/lib/hooks/useSPFxThemeInfo.d.ts +2 -0
- package/lib/hooks/useSPFxThemeInfo.d.ts.map +1 -1
- package/lib/hooks/useSPFxThemeInfo.js +2 -0
- package/lib/hooks/useSPFxThemeInfo.js.map +1 -1
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/resize-observer.internal.d.ts +12 -2
- package/lib/utils/resize-observer.internal.d.ts.map +1 -1
- package/lib/utils/resize-observer.internal.js +12 -2
- package/lib/utils/resize-observer.internal.js.map +1 -1
- package/lib/utils/theme-subscription.internal.d.ts +12 -3
- package/lib/utils/theme-subscription.internal.d.ts.map +1 -1
- package/lib/utils/theme-subscription.internal.js +19 -3
- package/lib/utils/theme-subscription.internal.js.map +1 -1
- package/lib/utils/type-guards.internal.d.ts +78 -5
- package/lib/utils/type-guards.internal.d.ts.map +1 -1
- package/lib/utils/type-guards.internal.js +78 -5
- package/lib/utils/type-guards.internal.js.map +1 -1
- package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.d.ts +0 -4
- package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.d.ts.map +1 -1
- package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.js +30 -746
- package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.js.map +1 -1
- package/lib/webparts/spFxReactToolkitTest/components/demos/HttpClientDemo.d.ts +7 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/HttpClientDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/HttpClientDemo.js +131 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/HttpClientDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPContextDemo.d.ts +8 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPContextDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPContextDemo.js +158 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPContextDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPListDemo.d.ts +9 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPListDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPListDemo.js +159 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPListDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPOperationsDemo.d.ts +10 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPOperationsDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPOperationsDemo.js +141 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPOperationsDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchAdvancedDemo.d.ts +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchAdvancedDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchAdvancedDemo.js +62 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchAdvancedDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchBasicDemo.d.ts +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchBasicDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchBasicDemo.js +98 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchBasicDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchRefinersDemo.d.ts +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchRefinersDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchRefinersDemo.js +45 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchRefinersDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchSuggestionsDemo.d.ts +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchSuggestionsDemo.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchSuggestionsDemo.js +134 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/PnPSearchSuggestionsDemo.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/index.d.ts +13 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/index.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/index.js +18 -0
- package/lib/webparts/spFxReactToolkitTest/components/demos/index.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/InfoRow.d.ts +18 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/InfoRow.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/InfoRow.js +17 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/InfoRow.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/StatusBadge.d.ts +16 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/StatusBadge.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/StatusBadge.js +14 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/StatusBadge.js.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/index.d.ts +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/index.d.ts.map +1 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/index.js +6 -0
- package/lib/webparts/spFxReactToolkitTest/components/shared/index.js.map +1 -0
- package/package.json +14 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-observer.internal.d.ts","sourceRoot":"","sources":["../../src/utils/resize-observer.internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"resize-observer.internal.d.ts","sourceRoot":"","sources":["../../src/utils/resize-observer.internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,KAAK,IAAI,GAClD,IAAI,CAwBN"}
|
|
@@ -4,8 +4,18 @@ import { useEffect } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* Hook to observe element size changes using ResizeObserver
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Automatically sets up and cleans up ResizeObserver subscription.
|
|
8
|
+
* Calls onResize with undefined if element is undefined or ResizeObserver is not supported.
|
|
9
|
+
*
|
|
10
|
+
* @param element - DOM element to observe, or undefined to clear observation
|
|
11
|
+
* @param onResize - Callback invoked with {width, height} on size changes, or undefined when element is unavailable
|
|
12
|
+
* @returns void - Hook manages subscription lifecycle internally
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - Cleanup is handled automatically on unmount or when element changes
|
|
16
|
+
* - ResizeObserver polyfill is NOT included - requires browser support
|
|
17
|
+
* - Initial size is reported immediately after observation starts
|
|
18
|
+
*
|
|
9
19
|
* @internal
|
|
10
20
|
*/
|
|
11
21
|
export function useResizeObserver(element, onResize) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-observer.internal.js","sourceRoot":"","sources":["../../src/utils/resize-observer.internal.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,+CAA+C;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC
|
|
1
|
+
{"version":3,"file":"resize-observer.internal.js","sourceRoot":"","sources":["../../src/utils/resize-observer.internal.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,+CAA+C;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAgC,EAChC,QAAmD;IAEnD,SAAS,CAAC;QACR,4DAA4D;QAC5D,IAAI,CAAC,OAAO,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;YACtD,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QAED,wBAAwB;QACxB,IAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,UAAC,OAAO;YAC1C,KAAoB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE,CAAC;gBAAzB,IAAM,KAAK,gBAAA;gBACR,IAAA,KAAoB,KAAK,CAAC,WAAW,EAAnC,KAAK,WAAA,EAAE,MAAM,YAAsB,CAAC;gBAC5C,QAAQ,CAAC,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,kBAAkB;QAClB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1B,qBAAqB;QACrB,OAAO;YACL,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { IReadonlyTheme } from '@microsoft/sp-component-base';
|
|
2
2
|
/**
|
|
3
3
|
* Hook to subscribe to SPFx theme changes
|
|
4
|
-
* Automatically updates the provided setter when theme changes
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Automatically updates the provided setter when theme changes.
|
|
6
|
+
* Sets initial theme on mount and subscribes to themeChangedEvent.
|
|
7
|
+
*
|
|
8
|
+
* @param spfxContext - SPFx context object with serviceScope
|
|
9
|
+
* @param setTheme - Setter function to update theme state (receives IReadonlyTheme or undefined)
|
|
10
|
+
* @returns void - Hook manages subscription lifecycle internally
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - Initial theme is set synchronously on mount if available
|
|
14
|
+
* - Cleanup removes event listener automatically on unmount
|
|
15
|
+
* - Uses SPFx observer pattern for event subscription
|
|
16
|
+
*
|
|
8
17
|
* @internal
|
|
9
18
|
*/
|
|
10
19
|
export declare function useThemeSubscription(spfxContext: unknown, setTheme: (theme: IReadonlyTheme | undefined) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-subscription.internal.d.ts","sourceRoot":"","sources":["../../src/utils/theme-subscription.internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"theme-subscription.internal.d.ts","sourceRoot":"","sources":["../../src/utils/theme-subscription.internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AA8BnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,GACpD,IAAI,CAmCN"}
|
|
@@ -4,7 +4,14 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { ThemeProvider } from '@microsoft/sp-component-base';
|
|
5
5
|
/**
|
|
6
6
|
* Extract ThemeProvider from SPFx context
|
|
7
|
+
*
|
|
7
8
|
* Works with any SPFx context type (WebPart, ApplicationCustomizer, etc.)
|
|
9
|
+
* by consuming ThemeProvider service from the ServiceScope.
|
|
10
|
+
*
|
|
11
|
+
* @param spfxContext - Any SPFx context object (WebPartContext, ApplicationCustomizerContext, etc.)
|
|
12
|
+
* @returns ThemeProvider service instance from SPFx ServiceScope
|
|
13
|
+
* @throws Error if context does not have serviceScope
|
|
14
|
+
*
|
|
8
15
|
* @internal
|
|
9
16
|
*/
|
|
10
17
|
function getThemeProvider(spfxContext) {
|
|
@@ -18,10 +25,19 @@ function getThemeProvider(spfxContext) {
|
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
27
|
* Hook to subscribe to SPFx theme changes
|
|
21
|
-
* Automatically updates the provided setter when theme changes
|
|
22
28
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
29
|
+
* Automatically updates the provided setter when theme changes.
|
|
30
|
+
* Sets initial theme on mount and subscribes to themeChangedEvent.
|
|
31
|
+
*
|
|
32
|
+
* @param spfxContext - SPFx context object with serviceScope
|
|
33
|
+
* @param setTheme - Setter function to update theme state (receives IReadonlyTheme or undefined)
|
|
34
|
+
* @returns void - Hook manages subscription lifecycle internally
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - Initial theme is set synchronously on mount if available
|
|
38
|
+
* - Cleanup removes event listener automatically on unmount
|
|
39
|
+
* - Uses SPFx observer pattern for event subscription
|
|
40
|
+
*
|
|
25
41
|
* @internal
|
|
26
42
|
*/
|
|
27
43
|
export function useThemeSubscription(spfxContext, setTheme) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-subscription.internal.js","sourceRoot":"","sources":["../../src/utils/theme-subscription.internal.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D
|
|
1
|
+
{"version":3,"file":"theme-subscription.internal.js","sourceRoot":"","sources":["../../src/utils/theme-subscription.internal.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D;;;;;;;;;;;GAWG;AACH,SAAS,gBAAgB,CAAC,WAAoB;IAC5C,IAAM,GAAG,GAAG,WAEX,CAAC;IAEF,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,2CAA2C;IAC3C,yDAAyD;IACzD,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAoB,EACpB,QAAqD;IAErD,SAAS,CAAC;QACR,IAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAEpD,oBAAoB;QACpB,IAAM,YAAY,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,YAAY,EAAE,CAAC;YACjB,QAAQ,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC;QAED,uBAAuB;QACvB,IAAM,OAAO,GAAG,UAAC,IAAgC;YAC/C,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC;QAEF,+CAA+C;QAC/C,IAAM,QAAQ,GAAG;YACf,UAAU,EAAE,oBAAoB;YAChC,WAAW,EAAE,oBAAoB;YACjC,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE;gBACP,sCAAsC;YACxC,CAAC;YACD,MAAM,EAAE,OAAO;SAChB,CAAC;QAEF,6BAA6B;QAC7B,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEvD,qBAAqB;QACrB,OAAO;YACL,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;YAC3B,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -4,31 +4,104 @@ import type { BaseListViewCommandSet, BaseFieldCustomizer } from '@microsoft/sp-
|
|
|
4
4
|
import type { SPFxComponent, HostKind } from '../core/types';
|
|
5
5
|
/**
|
|
6
6
|
* Type guard: Check if instance is a WebPart
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* Uses duck typing (structural typing) to detect WebPart instances
|
|
9
|
+
* by checking for WebPart-specific properties: displayMode, domElement, render, context, properties.
|
|
10
|
+
*
|
|
11
|
+
* @template TProps - WebPart properties type
|
|
12
|
+
* @param instance - SPFx component instance to check
|
|
13
|
+
* @returns True if instance is a BaseClientSideWebPart, narrowing the type
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* if (isWebPart(instance)) {
|
|
18
|
+
* // instance is now typed as BaseClientSideWebPart<TProps>
|
|
19
|
+
* console.log(instance.displayMode);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
8
23
|
* @internal
|
|
9
24
|
*/
|
|
10
25
|
export declare function isWebPart<TProps extends {} = {}>(instance: unknown): instance is BaseClientSideWebPart<TProps>;
|
|
11
26
|
/**
|
|
12
27
|
* Type guard: Check if instance is an ApplicationCustomizer
|
|
13
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Uses duck typing (structural typing) to detect ApplicationCustomizer instances
|
|
30
|
+
* by checking for placeholderProvider in context and absence of displayMode.
|
|
31
|
+
*
|
|
32
|
+
* @template TProps - ApplicationCustomizer properties type
|
|
33
|
+
* @param instance - SPFx component instance to check
|
|
34
|
+
* @returns True if instance is a BaseApplicationCustomizer, narrowing the type
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* if (isApplicationCustomizer(instance)) {
|
|
39
|
+
* // instance is now typed as BaseApplicationCustomizer<TProps>
|
|
40
|
+
* console.log(instance.context.placeholderProvider);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
14
44
|
* @internal
|
|
15
45
|
*/
|
|
16
46
|
export declare function isApplicationCustomizer<TProps extends {} = {}>(instance: unknown): instance is BaseApplicationCustomizer<TProps>;
|
|
17
47
|
/**
|
|
18
48
|
* Type guard: Check if instance is a ListViewCommandSet
|
|
19
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* Uses duck typing (structural typing) to detect ListViewCommandSet instances
|
|
51
|
+
* by checking for onExecute and tryGetCommand methods.
|
|
52
|
+
*
|
|
53
|
+
* @template TProps - ListViewCommandSet properties type
|
|
54
|
+
* @param instance - SPFx component instance to check
|
|
55
|
+
* @returns True if instance is a BaseListViewCommandSet, narrowing the type
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* if (isListViewCommandSet(instance)) {
|
|
60
|
+
* // instance is now typed as BaseListViewCommandSet<TProps>
|
|
61
|
+
* instance.tryGetCommand('COMMAND_ID');
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
20
65
|
* @internal
|
|
21
66
|
*/
|
|
22
67
|
export declare function isListViewCommandSet<TProps extends {} = {}>(instance: unknown): instance is BaseListViewCommandSet<TProps>;
|
|
23
68
|
/**
|
|
24
69
|
* Type guard: Check if instance is a FieldCustomizer
|
|
25
|
-
*
|
|
70
|
+
*
|
|
71
|
+
* Uses duck typing (structural typing) to detect FieldCustomizer instances
|
|
72
|
+
* by checking for field in context and onRenderCell method.
|
|
73
|
+
*
|
|
74
|
+
* @template TProps - FieldCustomizer properties type
|
|
75
|
+
* @param instance - SPFx component instance to check
|
|
76
|
+
* @returns True if instance is a BaseFieldCustomizer, narrowing the type
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* if (isFieldCustomizer(instance)) {
|
|
81
|
+
* // instance is now typed as BaseFieldCustomizer<TProps>
|
|
82
|
+
* console.log(instance.context.field);
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
26
86
|
* @internal
|
|
27
87
|
*/
|
|
28
88
|
export declare function isFieldCustomizer<TProps extends {} = {}>(instance: unknown): instance is BaseFieldCustomizer<TProps>;
|
|
29
89
|
/**
|
|
30
90
|
* Detect the kind of SPFx component from an instance
|
|
31
|
-
*
|
|
91
|
+
*
|
|
92
|
+
* Checks the instance against all known SPFx component types and returns
|
|
93
|
+
* the corresponding HostKind discriminator.
|
|
94
|
+
*
|
|
95
|
+
* @template TProps - SPFx component properties type
|
|
96
|
+
* @param instance - SPFx component instance to detect
|
|
97
|
+
* @returns HostKind ('WebPart' | 'AppCustomizer' | 'CommandSet' | 'FieldCustomizer')
|
|
98
|
+
* @throws Error if unable to detect component type
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const kind = detectComponentKind(this); // 'WebPart'
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
32
105
|
* @internal
|
|
33
106
|
*/
|
|
34
107
|
export declare function detectComponentKind<TProps extends {} = {}>(instance: SPFxComponent<TProps>): HostKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-guards.internal.d.ts","sourceRoot":"","sources":["../../src/utils/type-guards.internal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAA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CAAC,MAAM,CAAC,GAC9B,QAAQ,CAUV"}
|
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
// Type guards for SPFx component detection using structural typing (duck typing)
|
|
3
3
|
/**
|
|
4
4
|
* Type guard: Check if instance is a WebPart
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* Uses duck typing (structural typing) to detect WebPart instances
|
|
7
|
+
* by checking for WebPart-specific properties: displayMode, domElement, render, context, properties.
|
|
8
|
+
*
|
|
9
|
+
* @template TProps - WebPart properties type
|
|
10
|
+
* @param instance - SPFx component instance to check
|
|
11
|
+
* @returns True if instance is a BaseClientSideWebPart, narrowing the type
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (isWebPart(instance)) {
|
|
16
|
+
* // instance is now typed as BaseClientSideWebPart<TProps>
|
|
17
|
+
* console.log(instance.displayMode);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
6
21
|
* @internal
|
|
7
22
|
*/
|
|
8
23
|
export function isWebPart(instance) {
|
|
@@ -18,7 +33,22 @@ export function isWebPart(instance) {
|
|
|
18
33
|
}
|
|
19
34
|
/**
|
|
20
35
|
* Type guard: Check if instance is an ApplicationCustomizer
|
|
21
|
-
*
|
|
36
|
+
*
|
|
37
|
+
* Uses duck typing (structural typing) to detect ApplicationCustomizer instances
|
|
38
|
+
* by checking for placeholderProvider in context and absence of displayMode.
|
|
39
|
+
*
|
|
40
|
+
* @template TProps - ApplicationCustomizer properties type
|
|
41
|
+
* @param instance - SPFx component instance to check
|
|
42
|
+
* @returns True if instance is a BaseApplicationCustomizer, narrowing the type
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* if (isApplicationCustomizer(instance)) {
|
|
47
|
+
* // instance is now typed as BaseApplicationCustomizer<TProps>
|
|
48
|
+
* console.log(instance.context.placeholderProvider);
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
22
52
|
* @internal
|
|
23
53
|
*/
|
|
24
54
|
export function isApplicationCustomizer(instance) {
|
|
@@ -36,7 +66,22 @@ export function isApplicationCustomizer(instance) {
|
|
|
36
66
|
}
|
|
37
67
|
/**
|
|
38
68
|
* Type guard: Check if instance is a ListViewCommandSet
|
|
39
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* Uses duck typing (structural typing) to detect ListViewCommandSet instances
|
|
71
|
+
* by checking for onExecute and tryGetCommand methods.
|
|
72
|
+
*
|
|
73
|
+
* @template TProps - ListViewCommandSet properties type
|
|
74
|
+
* @param instance - SPFx component instance to check
|
|
75
|
+
* @returns True if instance is a BaseListViewCommandSet, narrowing the type
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* if (isListViewCommandSet(instance)) {
|
|
80
|
+
* // instance is now typed as BaseListViewCommandSet<TProps>
|
|
81
|
+
* instance.tryGetCommand('COMMAND_ID');
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
40
85
|
* @internal
|
|
41
86
|
*/
|
|
42
87
|
export function isListViewCommandSet(instance) {
|
|
@@ -52,7 +97,22 @@ export function isListViewCommandSet(instance) {
|
|
|
52
97
|
}
|
|
53
98
|
/**
|
|
54
99
|
* Type guard: Check if instance is a FieldCustomizer
|
|
55
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* Uses duck typing (structural typing) to detect FieldCustomizer instances
|
|
102
|
+
* by checking for field in context and onRenderCell method.
|
|
103
|
+
*
|
|
104
|
+
* @template TProps - FieldCustomizer properties type
|
|
105
|
+
* @param instance - SPFx component instance to check
|
|
106
|
+
* @returns True if instance is a BaseFieldCustomizer, narrowing the type
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* if (isFieldCustomizer(instance)) {
|
|
111
|
+
* // instance is now typed as BaseFieldCustomizer<TProps>
|
|
112
|
+
* console.log(instance.context.field);
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
56
116
|
* @internal
|
|
57
117
|
*/
|
|
58
118
|
export function isFieldCustomizer(instance) {
|
|
@@ -70,7 +130,20 @@ export function isFieldCustomizer(instance) {
|
|
|
70
130
|
}
|
|
71
131
|
/**
|
|
72
132
|
* Detect the kind of SPFx component from an instance
|
|
73
|
-
*
|
|
133
|
+
*
|
|
134
|
+
* Checks the instance against all known SPFx component types and returns
|
|
135
|
+
* the corresponding HostKind discriminator.
|
|
136
|
+
*
|
|
137
|
+
* @template TProps - SPFx component properties type
|
|
138
|
+
* @param instance - SPFx component instance to detect
|
|
139
|
+
* @returns HostKind ('WebPart' | 'AppCustomizer' | 'CommandSet' | 'FieldCustomizer')
|
|
140
|
+
* @throws Error if unable to detect component type
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const kind = detectComponentKind(this); // 'WebPart'
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
74
147
|
* @internal
|
|
75
148
|
*/
|
|
76
149
|
export function detectComponentKind(instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-guards.internal.js","sourceRoot":"","sources":["../../src/utils/type-guards.internal.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,iFAAiF;AAUjF
|
|
1
|
+
{"version":3,"file":"type-guards.internal.js","sourceRoot":"","sources":["../../src/utils/type-guards.internal.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,iFAAiF;AAUjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CACvB,QAAiB;IAEjB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5D,IAAM,GAAG,GAAG,QAAmC,CAAC;IAEhD,OAAO,CACL,aAAa,IAAI,GAAG;QACpB,YAAY,IAAI,GAAG;QACnB,QAAQ,IAAI,GAAG;QACf,OAAO,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IAAM,GAAG,GAAG,QAAmC,CAAC;IAEhD,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAM,OAAO,GAAG,GAAG,CAAC,OAAkC,CAAC;IAEvD,OAAO,CACL,OAAO,IAAI,OAAO;QAClB,cAAc,IAAI,GAAG;QACrB,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU;QACtC,YAAY,IAAI,GAAG,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAA+B;IAE/B,IAAI,SAAS,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,uBAAuB,CAAC,QAAQ,CAAC;QAAE,OAAO,eAAe,CAAC;IAC9D,IAAI,oBAAoB,CAAC,QAAQ,CAAC;QAAE,OAAO,YAAY,CAAC;IACxD,IAAI,iBAAiB,CAAC,QAAQ,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAE1D,MAAM,IAAI,KAAK,CACb,uDAAuD;QACvD,oFAAoF,CACrF,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import '@pnp/sp/webs';
|
|
3
|
-
import '@pnp/sp/lists';
|
|
4
|
-
import '@pnp/sp/items';
|
|
5
|
-
import '@pnp/sp/site-users';
|
|
6
2
|
declare const SpFxReactToolkitTest: React.FC;
|
|
7
3
|
export default SpFxReactToolkitTest;
|
|
8
4
|
//# sourceMappingURL=SpFxReactToolkitTest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpFxReactToolkitTest.d.ts","sourceRoot":"","sources":["../../../../src/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SpFxReactToolkitTest.d.ts","sourceRoot":"","sources":["../../../../src/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA0F/B,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EA6/BjC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|