@apvee/spfx-react-toolkit 1.0.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.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2012 -0
  3. package/lib/core/atoms.internal.d.ts +53 -0
  4. package/lib/core/atoms.internal.d.ts.map +1 -0
  5. package/lib/core/atoms.internal.js +35 -0
  6. package/lib/core/atoms.internal.js.map +1 -0
  7. package/lib/core/context.internal.d.ts +23 -0
  8. package/lib/core/context.internal.d.ts.map +1 -0
  9. package/lib/core/context.internal.js +34 -0
  10. package/lib/core/context.internal.js.map +1 -0
  11. package/lib/core/index.d.ts +6 -0
  12. package/lib/core/index.d.ts.map +1 -0
  13. package/lib/core/index.js +6 -0
  14. package/lib/core/index.js.map +1 -0
  15. package/lib/core/provider-application-customizer.d.ts +57 -0
  16. package/lib/core/provider-application-customizer.d.ts.map +1 -0
  17. package/lib/core/provider-application-customizer.js +45 -0
  18. package/lib/core/provider-application-customizer.js.map +1 -0
  19. package/lib/core/provider-base.internal.d.ts +20 -0
  20. package/lib/core/provider-base.internal.d.ts.map +1 -0
  21. package/lib/core/provider-base.internal.js +126 -0
  22. package/lib/core/provider-base.internal.js.map +1 -0
  23. package/lib/core/provider-field-customizer.d.ts +58 -0
  24. package/lib/core/provider-field-customizer.d.ts.map +1 -0
  25. package/lib/core/provider-field-customizer.js +46 -0
  26. package/lib/core/provider-field-customizer.js.map +1 -0
  27. package/lib/core/provider-listview-commandset.d.ts +60 -0
  28. package/lib/core/provider-listview-commandset.d.ts.map +1 -0
  29. package/lib/core/provider-listview-commandset.js +48 -0
  30. package/lib/core/provider-listview-commandset.js.map +1 -0
  31. package/lib/core/provider-webpart.d.ts +48 -0
  32. package/lib/core/provider-webpart.d.ts.map +1 -0
  33. package/lib/core/provider-webpart.js +36 -0
  34. package/lib/core/provider-webpart.js.map +1 -0
  35. package/lib/core/types.d.ts +84 -0
  36. package/lib/core/types.d.ts.map +1 -0
  37. package/lib/core/types.js +4 -0
  38. package/lib/core/types.js.map +1 -0
  39. package/lib/hooks/index.d.ts +34 -0
  40. package/lib/hooks/index.d.ts.map +1 -0
  41. package/lib/hooks/index.js +34 -0
  42. package/lib/hooks/index.js.map +1 -0
  43. package/lib/hooks/useSPFxAadHttpClient.d.ts +231 -0
  44. package/lib/hooks/useSPFxAadHttpClient.d.ts.map +1 -0
  45. package/lib/hooks/useSPFxAadHttpClient.js +299 -0
  46. package/lib/hooks/useSPFxAadHttpClient.js.map +1 -0
  47. package/lib/hooks/useSPFxContainerInfo.d.ts +41 -0
  48. package/lib/hooks/useSPFxContainerInfo.d.ts.map +1 -0
  49. package/lib/hooks/useSPFxContainerInfo.js +47 -0
  50. package/lib/hooks/useSPFxContainerInfo.js.map +1 -0
  51. package/lib/hooks/useSPFxContainerSize.d.ts +119 -0
  52. package/lib/hooks/useSPFxContainerSize.d.ts.map +1 -0
  53. package/lib/hooks/useSPFxContainerSize.js +150 -0
  54. package/lib/hooks/useSPFxContainerSize.js.map +1 -0
  55. package/lib/hooks/useSPFxContext.d.ts +14 -0
  56. package/lib/hooks/useSPFxContext.d.ts.map +1 -0
  57. package/lib/hooks/useSPFxContext.js +16 -0
  58. package/lib/hooks/useSPFxContext.js.map +1 -0
  59. package/lib/hooks/useSPFxCorrelationInfo.d.ts +51 -0
  60. package/lib/hooks/useSPFxCorrelationInfo.d.ts.map +1 -0
  61. package/lib/hooks/useSPFxCorrelationInfo.js +58 -0
  62. package/lib/hooks/useSPFxCorrelationInfo.js.map +1 -0
  63. package/lib/hooks/useSPFxCrossSitePermissions.d.ts +81 -0
  64. package/lib/hooks/useSPFxCrossSitePermissions.d.ts.map +1 -0
  65. package/lib/hooks/useSPFxCrossSitePermissions.js +132 -0
  66. package/lib/hooks/useSPFxCrossSitePermissions.js.map +1 -0
  67. package/lib/hooks/useSPFxDisplayMode.d.ts +61 -0
  68. package/lib/hooks/useSPFxDisplayMode.d.ts.map +1 -0
  69. package/lib/hooks/useSPFxDisplayMode.js +69 -0
  70. package/lib/hooks/useSPFxDisplayMode.js.map +1 -0
  71. package/lib/hooks/useSPFxEnvironmentInfo.d.ts +63 -0
  72. package/lib/hooks/useSPFxEnvironmentInfo.d.ts.map +1 -0
  73. package/lib/hooks/useSPFxEnvironmentInfo.js +91 -0
  74. package/lib/hooks/useSPFxEnvironmentInfo.js.map +1 -0
  75. package/lib/hooks/useSPFxFluent9ThemeInfo.d.ts +105 -0
  76. package/lib/hooks/useSPFxFluent9ThemeInfo.d.ts.map +1 -0
  77. package/lib/hooks/useSPFxFluent9ThemeInfo.js +136 -0
  78. package/lib/hooks/useSPFxFluent9ThemeInfo.js.map +1 -0
  79. package/lib/hooks/useSPFxHubSiteInfo.d.ts +80 -0
  80. package/lib/hooks/useSPFxHubSiteInfo.d.ts.map +1 -0
  81. package/lib/hooks/useSPFxHubSiteInfo.js +127 -0
  82. package/lib/hooks/useSPFxHubSiteInfo.js.map +1 -0
  83. package/lib/hooks/useSPFxInstanceInfo.d.ts +41 -0
  84. package/lib/hooks/useSPFxInstanceInfo.d.ts.map +1 -0
  85. package/lib/hooks/useSPFxInstanceInfo.js +40 -0
  86. package/lib/hooks/useSPFxInstanceInfo.js.map +1 -0
  87. package/lib/hooks/useSPFxListInfo.d.ts +64 -0
  88. package/lib/hooks/useSPFxListInfo.d.ts.map +1 -0
  89. package/lib/hooks/useSPFxListInfo.js +70 -0
  90. package/lib/hooks/useSPFxListInfo.js.map +1 -0
  91. package/lib/hooks/useSPFxLocaleInfo.d.ts +123 -0
  92. package/lib/hooks/useSPFxLocaleInfo.d.ts.map +1 -0
  93. package/lib/hooks/useSPFxLocaleInfo.js +109 -0
  94. package/lib/hooks/useSPFxLocaleInfo.js.map +1 -0
  95. package/lib/hooks/useSPFxLogger.d.ts +108 -0
  96. package/lib/hooks/useSPFxLogger.d.ts.map +1 -0
  97. package/lib/hooks/useSPFxLogger.js +117 -0
  98. package/lib/hooks/useSPFxLogger.js.map +1 -0
  99. package/lib/hooks/useSPFxMSGraphClient.d.ts +200 -0
  100. package/lib/hooks/useSPFxMSGraphClient.d.ts.map +1 -0
  101. package/lib/hooks/useSPFxMSGraphClient.js +264 -0
  102. package/lib/hooks/useSPFxMSGraphClient.js.map +1 -0
  103. package/lib/hooks/useSPFxOneDriveAppData.d.ts +264 -0
  104. package/lib/hooks/useSPFxOneDriveAppData.d.ts.map +1 -0
  105. package/lib/hooks/useSPFxOneDriveAppData.js +395 -0
  106. package/lib/hooks/useSPFxOneDriveAppData.js.map +1 -0
  107. package/lib/hooks/useSPFxPageContext.d.ts +37 -0
  108. package/lib/hooks/useSPFxPageContext.d.ts.map +1 -0
  109. package/lib/hooks/useSPFxPageContext.js +49 -0
  110. package/lib/hooks/useSPFxPageContext.js.map +1 -0
  111. package/lib/hooks/useSPFxPageType.d.ts +82 -0
  112. package/lib/hooks/useSPFxPageType.d.ts.map +1 -0
  113. package/lib/hooks/useSPFxPageType.js +137 -0
  114. package/lib/hooks/useSPFxPageType.js.map +1 -0
  115. package/lib/hooks/useSPFxPerformance.d.ts +72 -0
  116. package/lib/hooks/useSPFxPerformance.d.ts.map +1 -0
  117. package/lib/hooks/useSPFxPerformance.js +167 -0
  118. package/lib/hooks/useSPFxPerformance.js.map +1 -0
  119. package/lib/hooks/useSPFxPermissions.d.ts +61 -0
  120. package/lib/hooks/useSPFxPermissions.d.ts.map +1 -0
  121. package/lib/hooks/useSPFxPermissions.js +73 -0
  122. package/lib/hooks/useSPFxPermissions.js.map +1 -0
  123. package/lib/hooks/useSPFxPnP.d.ts +539 -0
  124. package/lib/hooks/useSPFxPnP.d.ts.map +1 -0
  125. package/lib/hooks/useSPFxPnP.js +533 -0
  126. package/lib/hooks/useSPFxPnP.js.map +1 -0
  127. package/lib/hooks/useSPFxPnPContext.d.ts +290 -0
  128. package/lib/hooks/useSPFxPnPContext.d.ts.map +1 -0
  129. package/lib/hooks/useSPFxPnPContext.js +340 -0
  130. package/lib/hooks/useSPFxPnPContext.js.map +1 -0
  131. package/lib/hooks/useSPFxPnPList.d.ts +545 -0
  132. package/lib/hooks/useSPFxPnPList.d.ts.map +1 -0
  133. package/lib/hooks/useSPFxPnPList.js +906 -0
  134. package/lib/hooks/useSPFxPnPList.js.map +1 -0
  135. package/lib/hooks/useSPFxPnPSearch.d.ts +540 -0
  136. package/lib/hooks/useSPFxPnPSearch.d.ts.map +1 -0
  137. package/lib/hooks/useSPFxPnPSearch.js +672 -0
  138. package/lib/hooks/useSPFxPnPSearch.js.map +1 -0
  139. package/lib/hooks/useSPFxProperties.d.ts +80 -0
  140. package/lib/hooks/useSPFxProperties.d.ts.map +1 -0
  141. package/lib/hooks/useSPFxProperties.js +95 -0
  142. package/lib/hooks/useSPFxProperties.js.map +1 -0
  143. package/lib/hooks/useSPFxSPHttpClient.d.ts +218 -0
  144. package/lib/hooks/useSPFxSPHttpClient.d.ts.map +1 -0
  145. package/lib/hooks/useSPFxSPHttpClient.js +287 -0
  146. package/lib/hooks/useSPFxSPHttpClient.js.map +1 -0
  147. package/lib/hooks/useSPFxServiceScope.d.ts +107 -0
  148. package/lib/hooks/useSPFxServiceScope.d.ts.map +1 -0
  149. package/lib/hooks/useSPFxServiceScope.js +105 -0
  150. package/lib/hooks/useSPFxServiceScope.js.map +1 -0
  151. package/lib/hooks/useSPFxSiteInfo.d.ts +116 -0
  152. package/lib/hooks/useSPFxSiteInfo.d.ts.map +1 -0
  153. package/lib/hooks/useSPFxSiteInfo.js +109 -0
  154. package/lib/hooks/useSPFxSiteInfo.js.map +1 -0
  155. package/lib/hooks/useSPFxStorage.d.ts +81 -0
  156. package/lib/hooks/useSPFxStorage.d.ts.map +1 -0
  157. package/lib/hooks/useSPFxStorage.js +140 -0
  158. package/lib/hooks/useSPFxStorage.js.map +1 -0
  159. package/lib/hooks/useSPFxTeams.d.ts +63 -0
  160. package/lib/hooks/useSPFxTeams.d.ts.map +1 -0
  161. package/lib/hooks/useSPFxTeams.js +198 -0
  162. package/lib/hooks/useSPFxTeams.js.map +1 -0
  163. package/lib/hooks/useSPFxTenantProperty.d.ts +389 -0
  164. package/lib/hooks/useSPFxTenantProperty.d.ts.map +1 -0
  165. package/lib/hooks/useSPFxTenantProperty.js +683 -0
  166. package/lib/hooks/useSPFxTenantProperty.js.map +1 -0
  167. package/lib/hooks/useSPFxThemeInfo.d.ts +27 -0
  168. package/lib/hooks/useSPFxThemeInfo.d.ts.map +1 -0
  169. package/lib/hooks/useSPFxThemeInfo.js +33 -0
  170. package/lib/hooks/useSPFxThemeInfo.js.map +1 -0
  171. package/lib/hooks/useSPFxUserInfo.d.ts +47 -0
  172. package/lib/hooks/useSPFxUserInfo.d.ts.map +1 -0
  173. package/lib/hooks/useSPFxUserInfo.js +47 -0
  174. package/lib/hooks/useSPFxUserInfo.js.map +1 -0
  175. package/lib/hooks/useSPFxUserPhoto.d.ts +270 -0
  176. package/lib/hooks/useSPFxUserPhoto.d.ts.map +1 -0
  177. package/lib/hooks/useSPFxUserPhoto.js +346 -0
  178. package/lib/hooks/useSPFxUserPhoto.js.map +1 -0
  179. package/lib/index.d.ts +3 -0
  180. package/lib/index.d.ts.map +1 -0
  181. package/lib/index.js +3 -0
  182. package/lib/index.js.map +1 -0
  183. package/lib/utils/index.d.ts +1 -0
  184. package/lib/utils/index.d.ts.map +1 -0
  185. package/lib/utils/index.js +3 -0
  186. package/lib/utils/index.js.map +1 -0
  187. package/lib/utils/resize-observer.internal.d.ts +10 -0
  188. package/lib/utils/resize-observer.internal.d.ts.map +1 -0
  189. package/lib/utils/resize-observer.internal.js +34 -0
  190. package/lib/utils/resize-observer.internal.js.map +1 -0
  191. package/lib/utils/theme-subscription.internal.d.ts +11 -0
  192. package/lib/utils/theme-subscription.internal.d.ts.map +1 -0
  193. package/lib/utils/theme-subscription.internal.js +58 -0
  194. package/lib/utils/theme-subscription.internal.js.map +1 -0
  195. package/lib/utils/type-guards.internal.d.ts +35 -0
  196. package/lib/utils/type-guards.internal.d.ts.map +1 -0
  197. package/lib/utils/type-guards.internal.js +88 -0
  198. package/lib/utils/type-guards.internal.js.map +1 -0
  199. package/lib/webparts/spFxReactToolkitTest/SpFxReactToolkitTestWebPart.d.ts +13 -0
  200. package/lib/webparts/spFxReactToolkitTest/SpFxReactToolkitTestWebPart.d.ts.map +1 -0
  201. package/lib/webparts/spFxReactToolkitTest/SpFxReactToolkitTestWebPart.js +67 -0
  202. package/lib/webparts/spFxReactToolkitTest/SpFxReactToolkitTestWebPart.js.map +1 -0
  203. package/lib/webparts/spFxReactToolkitTest/SpFxReactToolkitTestWebPart.manifest.json +21 -0
  204. package/lib/webparts/spFxReactToolkitTest/assets/welcome-dark.png +0 -0
  205. package/lib/webparts/spFxReactToolkitTest/assets/welcome-light.png +0 -0
  206. package/lib/webparts/spFxReactToolkitTest/components/ISpFxReactToolkitTestProps.d.ts +8 -0
  207. package/lib/webparts/spFxReactToolkitTest/components/ISpFxReactToolkitTestProps.d.ts.map +1 -0
  208. package/lib/webparts/spFxReactToolkitTest/components/ISpFxReactToolkitTestProps.js +2 -0
  209. package/lib/webparts/spFxReactToolkitTest/components/ISpFxReactToolkitTestProps.js.map +1 -0
  210. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.d.ts +8 -0
  211. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.d.ts.map +1 -0
  212. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.js +1351 -0
  213. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.js.map +1 -0
  214. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.module.css +2 -0
  215. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.module.scss.d.ts +18 -0
  216. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.module.scss.d.ts.map +1 -0
  217. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.module.scss.js +19 -0
  218. package/lib/webparts/spFxReactToolkitTest/components/SpFxReactToolkitTest.module.scss.js.map +1 -0
  219. package/lib/webparts/spFxReactToolkitTest/loc/en-us.js +16 -0
  220. package/package.json +95 -0
@@ -0,0 +1,91 @@
1
+ // useSPFxEnvironmentInfo.ts
2
+ // Hook to access environment type information
3
+ import { useSPFxPageContext } from './useSPFxPageContext';
4
+ /**
5
+ * Hook to access SPFx environment type information
6
+ *
7
+ * Detects the current host environment:
8
+ * - Local: Local workbench (localhost)
9
+ * - SharePoint: SharePoint Online
10
+ * - SharePointOnPrem: SharePoint On-Premises
11
+ * - Teams: Microsoft Teams
12
+ * - Office: Office applications
13
+ * - Outlook: Outlook
14
+ *
15
+ * Useful for:
16
+ * - Environment-specific rendering
17
+ * - Feature availability checks
18
+ * - API endpoint selection
19
+ * - Debugging information
20
+ *
21
+ * @returns Environment information
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * function MyComponent() {
26
+ * const { type, isTeams, isLocal } = useSPFxEnvironmentInfo();
27
+ *
28
+ * if (isLocal) {
29
+ * return <div>Development Mode</div>;
30
+ * }
31
+ *
32
+ * if (isTeams) {
33
+ * return <TeamsSpecificUI />;
34
+ * }
35
+ *
36
+ * return <SharePointUI />;
37
+ * }
38
+ * ```
39
+ */
40
+ export function useSPFxEnvironmentInfo() {
41
+ var _a;
42
+ var pageContext = useSPFxPageContext();
43
+ // Get legacy page context for environment detection
44
+ var legacy = pageContext.legacyPageContext;
45
+ // Check for SDK contexts (Teams, Office, Outlook)
46
+ var sdks = pageContext.sdks;
47
+ var isTeams = (sdks === null || sdks === void 0 ? void 0 : sdks.microsoftTeams) !== undefined;
48
+ var isOffice = (sdks === null || sdks === void 0 ? void 0 : sdks.office) !== undefined;
49
+ var isOutlook = (sdks === null || sdks === void 0 ? void 0 : sdks.outlook) !== undefined;
50
+ // Check for local workbench
51
+ var webUrl = pageContext.web.absoluteUrl.toLowerCase();
52
+ var isLocal = webUrl.indexOf('localhost') !== -1 ||
53
+ webUrl.indexOf('127.0.0.1') !== -1;
54
+ // Check for workbench (local or hosted)
55
+ var isWorkbench = isLocal ||
56
+ webUrl.indexOf('workbench.aspx') !== -1 ||
57
+ webUrl.indexOf('_layouts/15/workbench.aspx') !== -1;
58
+ // Check for SharePoint On-Premises
59
+ var isOnPrem = (_a = legacy === null || legacy === void 0 ? void 0 : legacy.isOnPremises) !== null && _a !== void 0 ? _a : false;
60
+ // Determine environment type (priority order: Local > Teams > Outlook > Office > OnPrem > SharePoint)
61
+ var type;
62
+ if (isLocal) {
63
+ type = 'Local';
64
+ }
65
+ else if (isTeams) {
66
+ type = 'Teams';
67
+ }
68
+ else if (isOutlook) {
69
+ type = 'Outlook';
70
+ }
71
+ else if (isOffice) {
72
+ type = 'Office';
73
+ }
74
+ else if (isOnPrem) {
75
+ type = 'SharePointOnPrem';
76
+ }
77
+ else {
78
+ type = 'SharePoint';
79
+ }
80
+ return {
81
+ type: type,
82
+ isLocal: isLocal,
83
+ isWorkbench: isWorkbench,
84
+ isSharePoint: type === 'SharePoint',
85
+ isSharePointOnPrem: type === 'SharePointOnPrem',
86
+ isTeams: isTeams,
87
+ isOffice: isOffice,
88
+ isOutlook: isOutlook,
89
+ };
90
+ }
91
+ //# sourceMappingURL=useSPFxEnvironmentInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxEnvironmentInfo.js","sourceRoot":"","sources":["../../src/hooks/useSPFxEnvironmentInfo.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,8CAA8C;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA0C1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,sBAAsB;;IACpC,IAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IAEzC,oDAAoD;IACpD,IAAM,MAAM,GAAI,WAMd,CAAC,iBAAiB,CAAC;IAErB,kDAAkD;IAClD,IAAM,IAAI,GAAI,WAMZ,CAAC,IAAI,CAAC;IAER,IAAM,OAAO,GAAG,CAA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ACtB,CAAC;IAED,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,WAAW,aAAA;QACX,YAAY,EAAE,IAAI,KAAK,YAAY;QACnC,kBAAkB,EAAE,IAAI,KAAK,kBAAkB;QAC/C,OAAO,SAAA;QACP,QAAQ,UAAA;QACR,SAAS,WAAA;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,105 @@
1
+ import type { Theme } from '@fluentui/react-theme';
2
+ /**
3
+ * Return type for useSPFxFluent9ThemeInfo hook
4
+ */
5
+ export interface SPFxFluent9ThemeInfo {
6
+ /** Fluent UI 9 theme object ready to use with FluentProvider */
7
+ readonly theme: Theme;
8
+ /** Whether the component is running in Microsoft Teams */
9
+ readonly isTeams: boolean;
10
+ /** Teams theme name if running in Teams ('default', 'dark', 'contrast') */
11
+ readonly teamsTheme?: string;
12
+ }
13
+ /**
14
+ * Hook for accessing Fluent UI 9 theme based on SPFx context
15
+ *
16
+ * Automatically detects the execution context and provides the appropriate
17
+ * Fluent UI 9 theme:
18
+ * - **In Microsoft Teams**: Returns native Teams themes (light/dark/contrast)
19
+ * - **In SharePoint**: Converts SPFx theme (v8) to Fluent UI 9 theme
20
+ * - **Fallback**: Returns webLightTheme if no theme available
21
+ *
22
+ * The hook uses memoization to avoid expensive theme conversions on every render.
23
+ * Theme updates are automatically handled when the user switches themes in
24
+ * SharePoint or Teams through the SPFxProvider's theme subscription mechanism.
25
+ *
26
+ * Priority order:
27
+ * 1. Teams theme (if running in Teams context)
28
+ * 2. SPFx theme converted to Fluent UI 9
29
+ * 3. Default webLightTheme
30
+ *
31
+ * Useful for:
32
+ * - Wrapping components with FluentProvider
33
+ * - Ensuring consistent theming across SharePoint and Teams
34
+ * - Automatic theme switching when user changes Teams/SharePoint theme
35
+ * - Building Fluent UI 9 applications in SPFx
36
+ *
37
+ * @returns Theme information including Fluent UI 9 theme and context details
38
+ *
39
+ * @example Basic usage with FluentProvider
40
+ * ```tsx
41
+ * import { FluentProvider } from '@fluentui/react-components';
42
+ *
43
+ * function MyWebPart() {
44
+ * const { theme } = useSPFxFluent9ThemeInfo();
45
+ *
46
+ * return (
47
+ * <FluentProvider theme={theme}>
48
+ * <MyApp />
49
+ * </FluentProvider>
50
+ * );
51
+ * }
52
+ * ```
53
+ *
54
+ * @example Accessing context information
55
+ * ```tsx
56
+ * function MyComponent() {
57
+ * const { theme, isTeams, teamsTheme } = useSPFxFluent9ThemeInfo();
58
+ *
59
+ * return (
60
+ * <div>
61
+ * <p>Running in Teams: {isTeams ? 'Yes' : 'No'}</p>
62
+ * {isTeams && <p>Teams theme: {teamsTheme}</p>}
63
+ * <FluentProvider theme={theme}>
64
+ * <Button>Themed Button</Button>
65
+ * </FluentProvider>
66
+ * </div>
67
+ * );
68
+ * }
69
+ * ```
70
+ *
71
+ * @example Conditional rendering based on theme
72
+ * ```tsx
73
+ * function ThemedComponent() {
74
+ * const { theme, teamsTheme } = useSPFxFluent9ThemeInfo();
75
+ *
76
+ * const isDarkTheme = teamsTheme === 'dark';
77
+ *
78
+ * return (
79
+ * <FluentProvider theme={theme}>
80
+ * {isDarkTheme ? <DarkModeIcon /> : <LightModeIcon />}
81
+ * </FluentProvider>
82
+ * );
83
+ * }
84
+ * ```
85
+ *
86
+ * @example Using with Fluent UI 9 components
87
+ * ```tsx
88
+ * import { FluentProvider, Button, Card } from '@fluentui/react-components';
89
+ *
90
+ * function MyWebPart() {
91
+ * const { theme, isTeams } = useSPFxFluent9ThemeInfo();
92
+ *
93
+ * return (
94
+ * <FluentProvider theme={theme}>
95
+ * <Card>
96
+ * <h3>Hello from {isTeams ? 'Teams' : 'SharePoint'}!</h3>
97
+ * <Button appearance="primary">Click me</Button>
98
+ * </Card>
99
+ * </FluentProvider>
100
+ * );
101
+ * }
102
+ * ```
103
+ */
104
+ export declare function useSPFxFluent9ThemeInfo(): SPFxFluent9ThemeInfo;
105
+ //# sourceMappingURL=useSPFxFluent9ThemeInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxFluent9ThemeInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useSPFxFluent9ThemeInfo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAWnD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,CAyB9D"}
@@ -0,0 +1,136 @@
1
+ // useSPFxFluent9ThemeInfo.ts
2
+ // Hook for accessing Fluent UI 9 theme based on SPFx context
3
+ import { useMemo } from 'react';
4
+ import { webLightTheme, teamsLightTheme, teamsDarkTheme, teamsHighContrastTheme } from '@fluentui/react-theme';
5
+ import { createV9Theme } from '@fluentui/react-migration-v8-v9';
6
+ import { useSPFxThemeInfo } from './useSPFxThemeInfo';
7
+ import { useSPFxTeams } from './useSPFxTeams';
8
+ /**
9
+ * Hook for accessing Fluent UI 9 theme based on SPFx context
10
+ *
11
+ * Automatically detects the execution context and provides the appropriate
12
+ * Fluent UI 9 theme:
13
+ * - **In Microsoft Teams**: Returns native Teams themes (light/dark/contrast)
14
+ * - **In SharePoint**: Converts SPFx theme (v8) to Fluent UI 9 theme
15
+ * - **Fallback**: Returns webLightTheme if no theme available
16
+ *
17
+ * The hook uses memoization to avoid expensive theme conversions on every render.
18
+ * Theme updates are automatically handled when the user switches themes in
19
+ * SharePoint or Teams through the SPFxProvider's theme subscription mechanism.
20
+ *
21
+ * Priority order:
22
+ * 1. Teams theme (if running in Teams context)
23
+ * 2. SPFx theme converted to Fluent UI 9
24
+ * 3. Default webLightTheme
25
+ *
26
+ * Useful for:
27
+ * - Wrapping components with FluentProvider
28
+ * - Ensuring consistent theming across SharePoint and Teams
29
+ * - Automatic theme switching when user changes Teams/SharePoint theme
30
+ * - Building Fluent UI 9 applications in SPFx
31
+ *
32
+ * @returns Theme information including Fluent UI 9 theme and context details
33
+ *
34
+ * @example Basic usage with FluentProvider
35
+ * ```tsx
36
+ * import { FluentProvider } from '@fluentui/react-components';
37
+ *
38
+ * function MyWebPart() {
39
+ * const { theme } = useSPFxFluent9ThemeInfo();
40
+ *
41
+ * return (
42
+ * <FluentProvider theme={theme}>
43
+ * <MyApp />
44
+ * </FluentProvider>
45
+ * );
46
+ * }
47
+ * ```
48
+ *
49
+ * @example Accessing context information
50
+ * ```tsx
51
+ * function MyComponent() {
52
+ * const { theme, isTeams, teamsTheme } = useSPFxFluent9ThemeInfo();
53
+ *
54
+ * return (
55
+ * <div>
56
+ * <p>Running in Teams: {isTeams ? 'Yes' : 'No'}</p>
57
+ * {isTeams && <p>Teams theme: {teamsTheme}</p>}
58
+ * <FluentProvider theme={theme}>
59
+ * <Button>Themed Button</Button>
60
+ * </FluentProvider>
61
+ * </div>
62
+ * );
63
+ * }
64
+ * ```
65
+ *
66
+ * @example Conditional rendering based on theme
67
+ * ```tsx
68
+ * function ThemedComponent() {
69
+ * const { theme, teamsTheme } = useSPFxFluent9ThemeInfo();
70
+ *
71
+ * const isDarkTheme = teamsTheme === 'dark';
72
+ *
73
+ * return (
74
+ * <FluentProvider theme={theme}>
75
+ * {isDarkTheme ? <DarkModeIcon /> : <LightModeIcon />}
76
+ * </FluentProvider>
77
+ * );
78
+ * }
79
+ * ```
80
+ *
81
+ * @example Using with Fluent UI 9 components
82
+ * ```tsx
83
+ * import { FluentProvider, Button, Card } from '@fluentui/react-components';
84
+ *
85
+ * function MyWebPart() {
86
+ * const { theme, isTeams } = useSPFxFluent9ThemeInfo();
87
+ *
88
+ * return (
89
+ * <FluentProvider theme={theme}>
90
+ * <Card>
91
+ * <h3>Hello from {isTeams ? 'Teams' : 'SharePoint'}!</h3>
92
+ * <Button appearance="primary">Click me</Button>
93
+ * </Card>
94
+ * </FluentProvider>
95
+ * );
96
+ * }
97
+ * ```
98
+ */
99
+ export function useSPFxFluent9ThemeInfo() {
100
+ var teamsInfo = useSPFxTeams();
101
+ var spfxTheme = useSPFxThemeInfo();
102
+ var theme = useMemo(function () {
103
+ // Priority 1: Teams theme (native Teams themes for better integration)
104
+ if (teamsInfo.supported && teamsInfo.theme) {
105
+ return getTeamsFluentTheme(teamsInfo.theme);
106
+ }
107
+ // Priority 2: Convert SPFx theme to Fluent UI 9
108
+ if (spfxTheme) {
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ return createV9Theme(spfxTheme);
111
+ }
112
+ // Priority 3: Fallback to default light theme
113
+ return webLightTheme;
114
+ }, [teamsInfo.supported, teamsInfo.theme, spfxTheme]);
115
+ return {
116
+ theme: theme,
117
+ isTeams: teamsInfo.supported,
118
+ teamsTheme: teamsInfo.theme
119
+ };
120
+ }
121
+ /**
122
+ * Maps Teams theme name to corresponding Fluent UI 9 theme
123
+ * @internal
124
+ */
125
+ function getTeamsFluentTheme(teamsThemeName) {
126
+ switch (teamsThemeName) {
127
+ case 'dark':
128
+ return teamsDarkTheme;
129
+ case 'highContrast':
130
+ return teamsHighContrastTheme;
131
+ case 'default':
132
+ default:
133
+ return teamsLightTheme;
134
+ }
135
+ }
136
+ //# sourceMappingURL=useSPFxFluent9ThemeInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxFluent9ThemeInfo.js","sourceRoot":"","sources":["../../src/hooks/useSPFxFluent9ThemeInfo.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,6DAA6D;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,sBAAsB,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,80 @@
1
+ /**
2
+ * Return type for useSPFxHubSiteInfo hook
3
+ */
4
+ export interface SPFxHubSiteInfo {
5
+ /** Whether the current site is associated with a hub site */
6
+ readonly isHubSite: boolean;
7
+ /** Hub site ID (GUID) if associated, undefined otherwise */
8
+ readonly hubSiteId: string | undefined;
9
+ /** Hub site URL (fetched via REST API) */
10
+ readonly hubSiteUrl: string | undefined;
11
+ /** Whether hub site URL is being loaded */
12
+ readonly isLoading: boolean;
13
+ /** Error during hub site URL fetch */
14
+ readonly error: Error | undefined;
15
+ }
16
+ /**
17
+ * Hook for Hub Site information
18
+ *
19
+ * Provides information about SharePoint Hub Site association:
20
+ * - isHubSite: Whether site is associated with a hub
21
+ * - hubSiteId: Unique hub site identifier (GUID) from pageContext
22
+ * - hubSiteUrl: Hub site URL (fetched via REST API)
23
+ * - isLoading: Loading state for hub URL fetch
24
+ * - error: Error during hub URL fetch
25
+ *
26
+ * Hub Sites are modern SharePoint feature that allow:
27
+ * - Unified navigation across related sites
28
+ * - Shared branding and theming
29
+ * - Content rollup from associated sites
30
+ * - Centralized search and navigation
31
+ *
32
+ * Use this hook to:
33
+ * - Detect hub site association
34
+ * - Get hub site ID and URL
35
+ * - Implement hub-aware navigation
36
+ *
37
+ * Note: hubSiteUrl is fetched asynchronously via REST API when isHubSite is true.
38
+ *
39
+ * @returns Hub site information (isHubSite, hubSiteId, hubSiteUrl, isLoading, error)
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * function MyComponent() {
44
+ * const { isHubSite, hubSiteId, hubSiteUrl, isLoading } = useSPFxHubSiteInfo();
45
+ *
46
+ * if (!isHubSite) {
47
+ * return <div>Not part of a hub site</div>;
48
+ * }
49
+ *
50
+ * if (isLoading) {
51
+ * return <Spinner label="Loading hub info..." />;
52
+ * }
53
+ *
54
+ * return (
55
+ * <div>
56
+ * <h3>Hub Site Info</h3>
57
+ * <p>Hub ID: {hubSiteId}</p>
58
+ * <a href={hubSiteUrl}>Go to Hub</a>
59
+ * </div>
60
+ * );
61
+ * }
62
+ * ```
63
+ *
64
+ * @example Hub-aware navigation
65
+ * ```tsx
66
+ * function HubNavigation() {
67
+ * const { isHubSite, hubSiteUrl, isLoading } = useSPFxHubSiteInfo();
68
+ *
69
+ * if (!isHubSite || isLoading) return null;
70
+ *
71
+ * return (
72
+ * <nav>
73
+ * <a href={hubSiteUrl}>← Back to Hub</a>
74
+ * </nav>
75
+ * );
76
+ * }
77
+ * ```
78
+ */
79
+ export declare function useSPFxHubSiteInfo(): SPFxHubSiteInfo;
80
+ //# sourceMappingURL=useSPFxHubSiteInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxHubSiteInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useSPFxHubSiteInfo.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAyEpD"}
@@ -0,0 +1,127 @@
1
+ // useSPFxHubSiteInfo.ts
2
+ // Hook for Hub Site information
3
+ import { useState, useEffect } from 'react';
4
+ import { SPHttpClient } from '@microsoft/sp-http';
5
+ import { useSPFxPageContext } from './useSPFxPageContext';
6
+ import { useSPFxSPHttpClient } from './useSPFxSPHttpClient';
7
+ /**
8
+ * Hook for Hub Site information
9
+ *
10
+ * Provides information about SharePoint Hub Site association:
11
+ * - isHubSite: Whether site is associated with a hub
12
+ * - hubSiteId: Unique hub site identifier (GUID) from pageContext
13
+ * - hubSiteUrl: Hub site URL (fetched via REST API)
14
+ * - isLoading: Loading state for hub URL fetch
15
+ * - error: Error during hub URL fetch
16
+ *
17
+ * Hub Sites are modern SharePoint feature that allow:
18
+ * - Unified navigation across related sites
19
+ * - Shared branding and theming
20
+ * - Content rollup from associated sites
21
+ * - Centralized search and navigation
22
+ *
23
+ * Use this hook to:
24
+ * - Detect hub site association
25
+ * - Get hub site ID and URL
26
+ * - Implement hub-aware navigation
27
+ *
28
+ * Note: hubSiteUrl is fetched asynchronously via REST API when isHubSite is true.
29
+ *
30
+ * @returns Hub site information (isHubSite, hubSiteId, hubSiteUrl, isLoading, error)
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * function MyComponent() {
35
+ * const { isHubSite, hubSiteId, hubSiteUrl, isLoading } = useSPFxHubSiteInfo();
36
+ *
37
+ * if (!isHubSite) {
38
+ * return <div>Not part of a hub site</div>;
39
+ * }
40
+ *
41
+ * if (isLoading) {
42
+ * return <Spinner label="Loading hub info..." />;
43
+ * }
44
+ *
45
+ * return (
46
+ * <div>
47
+ * <h3>Hub Site Info</h3>
48
+ * <p>Hub ID: {hubSiteId}</p>
49
+ * <a href={hubSiteUrl}>Go to Hub</a>
50
+ * </div>
51
+ * );
52
+ * }
53
+ * ```
54
+ *
55
+ * @example Hub-aware navigation
56
+ * ```tsx
57
+ * function HubNavigation() {
58
+ * const { isHubSite, hubSiteUrl, isLoading } = useSPFxHubSiteInfo();
59
+ *
60
+ * if (!isHubSite || isLoading) return null;
61
+ *
62
+ * return (
63
+ * <nav>
64
+ * <a href={hubSiteUrl}>← Back to Hub</a>
65
+ * </nav>
66
+ * );
67
+ * }
68
+ * ```
69
+ */
70
+ export function useSPFxHubSiteInfo() {
71
+ var _a;
72
+ var pageContext = useSPFxPageContext();
73
+ var _b = useSPFxSPHttpClient(), invoke = _b.invoke, baseUrl = _b.baseUrl;
74
+ var _c = useState(undefined), hubSiteUrl = _c[0], setHubSiteUrl = _c[1];
75
+ var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
76
+ var _e = useState(undefined), error = _e[0], setError = _e[1];
77
+ // Get hub site info from legacyPageContext
78
+ var legacy = pageContext.legacyPageContext;
79
+ var hubSiteId = legacy === null || legacy === void 0 ? void 0 : legacy.hubSiteId;
80
+ var isCurrentSiteTheHub = (_a = legacy === null || legacy === void 0 ? void 0 : legacy.isHubSite) !== null && _a !== void 0 ? _a : false;
81
+ var currentSiteUrl = pageContext.webAbsoluteUrl;
82
+ // Site is part of a hub if hubSiteId exists and is not empty GUID
83
+ var isHubSite = hubSiteId !== undefined &&
84
+ hubSiteId !== '' &&
85
+ hubSiteId !== '00000000-0000-0000-0000-000000000000';
86
+ // Fetch hub site URL when needed
87
+ useEffect(function () {
88
+ if (!isHubSite || !hubSiteId) {
89
+ return;
90
+ }
91
+ // OPTIMIZATION: If current site IS the hub site, use current URL directly
92
+ if (isCurrentSiteTheHub && currentSiteUrl) {
93
+ setHubSiteUrl(currentSiteUrl);
94
+ setIsLoading(false);
95
+ return;
96
+ }
97
+ // Otherwise, fetch hub URL via API (current site is associated to a hub)
98
+ setIsLoading(true);
99
+ setError(undefined);
100
+ // Use the web's hub site data endpoint to get hub URL
101
+ // This endpoint returns { value: "JSON_STRING" }, so we need to parse twice
102
+ invoke(function (client) {
103
+ return client.get("".concat(baseUrl, "/_api/web/hubsitedata(false)"), SPHttpClient.configurations.v1)
104
+ .then(function (res) { return res.json(); })
105
+ .then(function (response) { return JSON.parse(response.value); });
106
+ })
107
+ .then(function (data) {
108
+ if (data.url) {
109
+ setHubSiteUrl(data.url);
110
+ }
111
+ setIsLoading(false);
112
+ })
113
+ .catch(function (err) {
114
+ var errorObj = err instanceof Error ? err : new Error(String(err));
115
+ setError(errorObj);
116
+ setIsLoading(false);
117
+ });
118
+ }, [isHubSite, hubSiteId, isCurrentSiteTheHub, currentSiteUrl, invoke, baseUrl]);
119
+ return {
120
+ isHubSite: isHubSite,
121
+ hubSiteId: isHubSite ? hubSiteId : undefined,
122
+ hubSiteUrl: hubSiteUrl,
123
+ isLoading: isLoading,
124
+ error: error,
125
+ };
126
+ }
127
+ //# sourceMappingURL=useSPFxHubSiteInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxHubSiteInfo.js","sourceRoot":"","sources":["../../src/hooks/useSPFxHubSiteInfo.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,gCAAgC;AAEhC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAsB5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,UAAU,kBAAkB;;IAChC,IAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IACnC,IAAA,KAAsB,mBAAmB,EAAE,EAAzC,MAAM,YAAA,EAAE,OAAO,aAA0B,CAAC;IAE5C,IAAA,KAA8B,QAAQ,CAAqB,SAAS,CAAC,EAApE,UAAU,QAAA,EAAE,aAAa,QAA2C,CAAC;IACtE,IAAA,KAA4B,QAAQ,CAAU,KAAK,CAAC,EAAnD,SAAS,QAAA,EAAE,YAAY,QAA4B,CAAC;IACrD,IAAA,KAAoB,QAAQ,CAAoB,SAAS,CAAC,EAAzD,KAAK,QAAA,EAAE,QAAQ,QAA0C,CAAC;IAEjE,2CAA2C;IAC3C,IAAM,MAAM,GAAI,WAMd,CAAC,iBAAiB,CAAC;IAErB,IAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAC;IACpC,IAAM,m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K,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACrE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEjF,OAAO;QACL,SAAS,WAAA;QACT,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC5C,UAAU,YAAA;QACV,SAAS,WAAA;QACT,KAAK,OAAA;KACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { HostKind } from '../core/types';
2
+ /**
3
+ * Return type for useSPFxInstanceInfo hook
4
+ */
5
+ export interface SPFxInstanceInfo {
6
+ /** Unique identifier for this SPFx instance */
7
+ readonly id: string;
8
+ /** Type of SPFx component (WebPart, AppCustomizer, etc.) */
9
+ readonly kind: HostKind;
10
+ }
11
+ /**
12
+ * Hook to access SPFx instance metadata
13
+ *
14
+ * Provides:
15
+ * - id: Unique identifier for this SPFx instance
16
+ * - kind: Type of component ('WebPart', 'AppCustomizer', etc.)
17
+ *
18
+ * Useful for:
19
+ * - Logging and telemetry
20
+ * - Conditional logic based on host type
21
+ * - Scoped storage keys
22
+ * - Debug information
23
+ *
24
+ * @returns Instance metadata
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function MyComponent() {
29
+ * const { id, kind } = useSPFxInstanceInfo();
30
+ *
31
+ * return (
32
+ * <div>
33
+ * <p>Instance: {id}</p>
34
+ * <p>Type: {kind}</p>
35
+ * </div>
36
+ * );
37
+ * }
38
+ * ```
39
+ */
40
+ export declare function useSPFxInstanceInfo(): SPFxInstanceInfo;
41
+ //# sourceMappingURL=useSPFxInstanceInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxInstanceInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useSPFxInstanceInfo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAOtD"}
@@ -0,0 +1,40 @@
1
+ // useSPFxInstanceInfo.ts
2
+ // Hook to access SPFx instance metadata
3
+ import { useSPFxContext } from './useSPFxContext';
4
+ /**
5
+ * Hook to access SPFx instance metadata
6
+ *
7
+ * Provides:
8
+ * - id: Unique identifier for this SPFx instance
9
+ * - kind: Type of component ('WebPart', 'AppCustomizer', etc.)
10
+ *
11
+ * Useful for:
12
+ * - Logging and telemetry
13
+ * - Conditional logic based on host type
14
+ * - Scoped storage keys
15
+ * - Debug information
16
+ *
17
+ * @returns Instance metadata
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * function MyComponent() {
22
+ * const { id, kind } = useSPFxInstanceInfo();
23
+ *
24
+ * return (
25
+ * <div>
26
+ * <p>Instance: {id}</p>
27
+ * <p>Type: {kind}</p>
28
+ * </div>
29
+ * );
30
+ * }
31
+ * ```
32
+ */
33
+ export function useSPFxInstanceInfo() {
34
+ var _a = useSPFxContext(), instanceId = _a.instanceId, kind = _a.kind;
35
+ return {
36
+ id: instanceId,
37
+ kind: kind,
38
+ };
39
+ }
40
+ //# sourceMappingURL=useSPFxInstanceInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSPFxInstanceInfo.js","sourceRoot":"","sources":["../../src/hooks/useSPFxInstanceInfo.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,wCAAwC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,mBAAmB;IAC3B,IAAA,KAAuB,cAAc,EAAE,EAArC,UAAU,gBAAA,EAAE,IAAI,UAAqB,CAAC;IAE9C,OAAO;QACL,EAAE,EAAE,UAAU;QACd,IAAI,MAAA;KACL,CAAC;AACJ,CAAC"}