@apvee/spfx-react-toolkit 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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.map +1 -1
- package/lib/hooks/useSPFxAadHttpClient.js +5 -75
- 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 +4 -0
- package/lib/hooks/useSPFxHttpClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxHttpClient.js +8 -75
- package/lib/hooks/useSPFxHttpClient.js.map +1 -1
- package/lib/hooks/useSPFxMSGraphClient.d.ts.map +1 -1
- package/lib/hooks/useSPFxMSGraphClient.js +4 -74
- package/lib/hooks/useSPFxMSGraphClient.js.map +1 -1
- package/lib/hooks/useSPFxOneDriveAppData.d.ts +25 -0
- package/lib/hooks/useSPFxOneDriveAppData.d.ts.map +1 -1
- package/lib/hooks/useSPFxOneDriveAppData.js +121 -256
- 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.map +1 -1
- package/lib/hooks/useSPFxSPHttpClient.js +4 -74
- 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 +35 -752
- 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 +7 -7
|
@@ -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,MAAM,sCAAsC,CAAC;AACxG,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACT,MAAM,eAAe,CAAC;AAEvB
|
|
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,MAAM,sCAAsC,CAAC;AACxG,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACT,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,EAC9C,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAa3C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,EAC5D,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAgB/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,EACzD,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAa5C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,EACtD,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAiBzC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,EACxD,QAAQ,EAAE,aAAa,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,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,SAAS,IAAI,GAAG;QAChB,YAAY,IAAI,GAAG,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAiB;IAEjB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5D,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,qBAAqB,IAAI,OAAO;QAChC,YAAY,IAAI,GAAG;QACnB,CAAC,CAAC,aAAa,IAAI,GAAG,CAAC,CAAC,gBAAgB;KACzC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAiB;IAEjB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5D,IAAM,GAAG,GAAG,QAAmC,CAAC;IAEhD,OAAO,CACL,WAAW,IAAI,GAAG;QAClB,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU;QACnC,eAAe,IAAI,GAAG;QACtB,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;QACvC,SAAS,IAAI,GAAG;QAChB,YAAY,IAAI,GAAG,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAiB;IAEjB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5D,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,EA8/BjC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|