@equinor/fusion-framework-react-app 14.0.3 → 14.1.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.
Files changed (95) hide show
  1. package/README.md +9 -2
  2. package/dist/esm/ag-grid/community.js +12 -0
  3. package/dist/esm/ag-grid/community.js.map +1 -0
  4. package/dist/esm/ag-grid/enterprise.js +12 -0
  5. package/dist/esm/ag-grid/enterprise.js.map +1 -0
  6. package/dist/esm/ag-grid/react.js +12 -0
  7. package/dist/esm/ag-grid/react.js.map +1 -0
  8. package/dist/esm/ag-grid/testing.js +19 -0
  9. package/dist/esm/ag-grid/testing.js.map +1 -0
  10. package/dist/esm/ag-grid/theme.js +13 -0
  11. package/dist/esm/ag-grid/theme.js.map +1 -0
  12. package/dist/esm/create-component.js +1 -1
  13. package/dist/esm/msal/useToken.js +12 -3
  14. package/dist/esm/msal/useToken.js.map +1 -1
  15. package/dist/esm/version.js +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/dist/types/ag-grid/community.d.ts +11 -0
  18. package/dist/types/ag-grid/enterprise.d.ts +11 -0
  19. package/dist/types/ag-grid/react.d.ts +11 -0
  20. package/dist/types/ag-grid/testing.d.ts +18 -0
  21. package/dist/types/ag-grid/theme.d.ts +13 -0
  22. package/dist/types/create-component.d.ts +1 -1
  23. package/dist/types/version.d.ts +1 -1
  24. package/package.json +80 -25
  25. package/CHANGELOG.md +0 -2730
  26. package/docs/ag-grid.md +0 -70
  27. package/docs/analytics.md +0 -122
  28. package/docs/app.md +0 -148
  29. package/docs/apploader.md +0 -110
  30. package/docs/bookmark.md +0 -101
  31. package/docs/context.md +0 -86
  32. package/docs/feature-flag.md +0 -119
  33. package/docs/framework.md +0 -93
  34. package/docs/help-center.md +0 -88
  35. package/docs/http.md +0 -118
  36. package/docs/msal.md +0 -291
  37. package/docs/navigation.md +0 -80
  38. package/docs/routing.md +0 -86
  39. package/docs/settings.md +0 -139
  40. package/src/__tests__/render-app.test.tsx +0 -113
  41. package/src/__tests__/useStateSyncEvents.test.ts +0 -57
  42. package/src/ag-grid/useTheme.ts +0 -21
  43. package/src/analytics/README.md +0 -148
  44. package/src/analytics/index.ts +0 -9
  45. package/src/analytics/useTrackFeature.ts +0 -73
  46. package/src/apploader/Apploader.tsx +0 -50
  47. package/src/apploader/README.md +0 -81
  48. package/src/apploader/index.ts +0 -10
  49. package/src/apploader/useApploader.ts +0 -107
  50. package/src/bookmark/index.ts +0 -20
  51. package/src/bookmark/useBookmark.ts +0 -25
  52. package/src/bookmark/useCurrentBookmark.ts +0 -54
  53. package/src/context/index.ts +0 -14
  54. package/src/context/useContextProvider.ts +0 -12
  55. package/src/context/useCurrentContext.ts +0 -20
  56. package/src/create-component.tsx +0 -120
  57. package/src/create-legacy-app.tsx +0 -51
  58. package/src/feature-flag/README.md +0 -20
  59. package/src/feature-flag/enable-feature-flag.ts +0 -79
  60. package/src/feature-flag/index.ts +0 -17
  61. package/src/feature-flag/useFeature.ts +0 -90
  62. package/src/framework/index.ts +0 -14
  63. package/src/framework/useFrameworkCurrentContext.ts +0 -15
  64. package/src/help-center/README.md +0 -21
  65. package/src/help-center/event-name.ts +0 -1
  66. package/src/help-center/index.ts +0 -11
  67. package/src/help-center/useHelpCenter.ts +0 -162
  68. package/src/http/index.ts +0 -10
  69. package/src/http/selectors.ts +0 -9
  70. package/src/index.ts +0 -46
  71. package/src/make-component.tsx +0 -102
  72. package/src/msal/index.ts +0 -16
  73. package/src/msal/useAccessToken.ts +0 -26
  74. package/src/msal/useCurrentAccount.ts +0 -21
  75. package/src/msal/useToken.ts +0 -52
  76. package/src/navigation/index.ts +0 -10
  77. package/src/navigation/useNavigationModule.ts +0 -10
  78. package/src/navigation/useRouter.ts +0 -35
  79. package/src/render-app.ts +0 -35
  80. package/src/render-component.tsx +0 -55
  81. package/src/routing/index.ts +0 -33
  82. package/src/settings/README.md +0 -123
  83. package/src/settings/index.ts +0 -12
  84. package/src/settings/useAppSetting.ts +0 -113
  85. package/src/settings/useAppSettings.ts +0 -103
  86. package/src/settings/useAppSettingsStatus.ts +0 -52
  87. package/src/state/index.ts +0 -12
  88. package/src/state/useAppState.ts +0 -299
  89. package/src/state/useStateSyncEvents.ts +0 -59
  90. package/src/useAppEnvironmentVariables.ts +0 -59
  91. package/src/useAppModule.ts +0 -45
  92. package/src/useAppModules.ts +0 -21
  93. package/src/version.ts +0 -2
  94. package/tsconfig.json +0 -48
  95. package/vitest.config.ts +0 -15
@@ -1,162 +0,0 @@
1
- import { useCallback } from 'react';
2
- import useAppModule from '../useAppModule';
3
-
4
- import { EVENT_NAME } from './event-name.js';
5
-
6
- type HelpCenterEventDetailBase<
7
- T extends string,
8
- V extends Record<string, unknown> = Record<string, unknown>,
9
- > = {
10
- page: T;
11
- } & V;
12
-
13
- type OpenHelpDetail = HelpCenterEventDetailBase<'home'>;
14
-
15
- type OpenArticleDetail = HelpCenterEventDetailBase<
16
- 'article',
17
- {
18
- articleId: string;
19
- }
20
- >;
21
-
22
- type OpenFaqsDetail = HelpCenterEventDetailBase<'faqs'>;
23
-
24
- type OpenSearchDetail = HelpCenterEventDetailBase<
25
- 'search',
26
- {
27
- search: string;
28
- }
29
- >;
30
-
31
- type OpenGovernanceDetail = HelpCenterEventDetailBase<'governance'>;
32
-
33
- export type HelpCenterOpenEventDetail =
34
- | OpenHelpDetail
35
- | OpenArticleDetail
36
- | OpenFaqsDetail
37
- | OpenSearchDetail
38
- | OpenGovernanceDetail;
39
-
40
- /**
41
- * Interface for requesting help features.
42
- */
43
- export interface HelpCenter {
44
- /**
45
- * Requesting the portal to open the help sidesheet on the normal page
46
- */
47
- openHelp(): void;
48
-
49
- /**
50
- * Requesting the portal to open the help sidesheet on the article page.
51
- *
52
- * @param {string} articleId - The articleId, slug or identifier to show.
53
- */
54
- openArticle(articleId: string): void;
55
-
56
- /**
57
- * Requesting the portal to open the help sidesheet on the FAQs page.
58
- */
59
- openFaqs(): void;
60
-
61
- /**
62
- * Requesting the portal to open the help sidesheet on the search page.
63
- *
64
- * @param {string} search - The search string.
65
- */
66
- openSearch(search: string): void;
67
-
68
- /**
69
- * Requesting the portal to open the help sidesheet on the governance tab.
70
- */
71
- openGovernance(): void;
72
-
73
- /**
74
- * Requesting the portal to open the help sidesheet on the release notes page.
75
- */
76
- openReleaseNotes(): void;
77
- }
78
-
79
- /**
80
- * React hook that returns an API for opening the portal help-center sidesheet.
81
- *
82
- * Each method dispatches a framework event that the portal shell listens for
83
- * and opens the corresponding help page.
84
- *
85
- * @returns A {@link HelpCenter} object with methods to open specific help pages.
86
- *
87
- * @example
88
- * ```tsx
89
- * const helpCenter = useHelpCenter();
90
- * <Button onClick={() => helpCenter.openFaqs()}>FAQs</Button>
91
- * ```
92
- */
93
- export const useHelpCenter = (): HelpCenter => {
94
- const eventModule = useAppModule('event');
95
-
96
- const openHelp = useCallback((): void => {
97
- eventModule.dispatchEvent(EVENT_NAME, {
98
- detail: {
99
- page: 'home',
100
- },
101
- });
102
- }, [eventModule]);
103
-
104
- const openArticle = useCallback(
105
- (articleId: string): void => {
106
- eventModule.dispatchEvent(EVENT_NAME, {
107
- detail: {
108
- page: 'article',
109
- articleId: articleId,
110
- },
111
- });
112
- },
113
- [eventModule],
114
- );
115
-
116
- const openFaqs = useCallback((): void => {
117
- eventModule.dispatchEvent(EVENT_NAME, {
118
- detail: {
119
- page: 'faqs',
120
- },
121
- });
122
- }, [eventModule]);
123
-
124
- const openSearch = useCallback(
125
- (search: string): void => {
126
- eventModule.dispatchEvent(EVENT_NAME, {
127
- detail: {
128
- page: 'search',
129
- search: search,
130
- },
131
- });
132
- },
133
- [eventModule],
134
- );
135
-
136
- const openGovernance = useCallback((): void => {
137
- eventModule.dispatchEvent(EVENT_NAME, {
138
- detail: {
139
- page: 'governance',
140
- },
141
- });
142
- }, [eventModule]);
143
-
144
- const openReleaseNotes = useCallback((): void => {
145
- eventModule.dispatchEvent(EVENT_NAME, {
146
- detail: {
147
- page: 'release-notes',
148
- },
149
- });
150
- }, [eventModule]);
151
-
152
- return {
153
- openHelp,
154
- openArticle,
155
- openFaqs,
156
- openSearch,
157
- openGovernance,
158
- openReleaseNotes,
159
- };
160
- };
161
-
162
- export default useHelpCenter;
package/src/http/index.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * HTTP sub-path entry-point.
3
- *
4
- * Re-exports hooks from `@equinor/fusion-framework-react-module-http`,
5
- * including {@link useHttpClient} for making authenticated HTTP requests
6
- * from within a Fusion application.
7
- *
8
- * @packageDocumentation
9
- */
10
- export * from '@equinor/fusion-framework-react-module-http';
@@ -1,9 +0,0 @@
1
- /**
2
- * HTTP selector utilities.
3
- *
4
- * Re-exports response-selector helpers (e.g. JSON, blob, text selectors)
5
- * from `@equinor/fusion-framework-module-http/selectors`.
6
- *
7
- * @packageDocumentation
8
- */
9
- export * from '@equinor/fusion-framework-module-http/selectors';
package/src/index.ts DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * React bindings for building Fusion Framework applications.
5
- *
6
- * Provides the main entry-point helpers (`renderApp`, `createComponent`, `makeComponent`)
7
- * plus React hooks for accessing framework modules (HTTP, auth, context, navigation, etc.)
8
- * from within a Fusion app.
9
- *
10
- * @remarks
11
- * This is the primary package application developers depend on when building
12
- * React-based Fusion apps. It re-exports core types from `@equinor/fusion-framework-app`
13
- * and adds React-specific rendering, hooks, and sub-path entry-points for optional
14
- * modules such as MSAL, feature flags, bookmarks, analytics, and settings.
15
- */
16
-
17
- export type {
18
- AppConfig,
19
- AppEnv,
20
- AppModuleInitiator,
21
- AppModules,
22
- AppModulesInstance,
23
- AppRenderFn,
24
- IAppConfigurator,
25
- } from '@equinor/fusion-framework-app';
26
-
27
- export type { Fusion } from '@equinor/fusion-framework-react';
28
-
29
- export { AppManifest } from '@equinor/fusion-framework-module-app';
30
-
31
- export { useAppModule } from './useAppModule';
32
- export { useAppModules } from './useAppModules';
33
- export { useAppEnvironmentVariables } from './useAppEnvironmentVariables';
34
-
35
- export { makeComponent, ComponentRenderArgs } from './make-component';
36
-
37
- export { createLegacyApp } from './create-legacy-app';
38
-
39
- export { createComponent } from './create-component';
40
- export { renderApp } from './render-app';
41
- export { renderComponent } from './render-component';
42
-
43
- export type { ComponentRenderer } from './create-component';
44
- export type { RenderTeardown } from './render-component';
45
-
46
- export { default } from './render-app';
@@ -1,102 +0,0 @@
1
- import type React from 'react';
2
- import { lazy } from 'react';
3
-
4
- import { FrameworkProvider } from '@equinor/fusion-framework-react';
5
- import type { Fusion } from '@equinor/fusion-framework-react';
6
-
7
- import { type AppEnv, configureModules } from '@equinor/fusion-framework-app';
8
- import type { AppModuleInitiator, AppModulesInstance } from '@equinor/fusion-framework-app';
9
-
10
- import type { AnyModule } from '@equinor/fusion-framework-module';
11
-
12
- import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
13
-
14
- import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-react-module';
15
-
16
- /**
17
- * Arguments supplied when rendering a Fusion app component.
18
- *
19
- * @template TFusion - The Fusion framework instance type.
20
- * @template TEnv - The application environment type.
21
- */
22
- export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv> = {
23
- /** The Fusion framework instance. */
24
- fusion: TFusion;
25
- /** The application environment (manifest, config, basename, etc.). */
26
- env: TEnv;
27
- };
28
-
29
- /**
30
- * Factory function that receives a Fusion instance and environment and returns a
31
- * lazy React component ready to be rendered.
32
- *
33
- * @template TFusion - The Fusion framework instance type.
34
- * @template TEnv - The application environment type.
35
- */
36
- export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (
37
- fusion: TFusion,
38
- env: TEnv,
39
- ) => React.LazyExoticComponent<React.ComponentType>;
40
-
41
- /**
42
- * Creates a lazy loading React Component that initializes and configures modules,
43
- * then provides the necessary context to both the Fusion framework and the configured modules.
44
- * This function is particularly useful for setting up a React application with modular architecture,
45
- * allowing for lazy loading of components along with their dependencies.
46
- *
47
- * __Exposed providers__:
48
- * - {@link @equinor/fusion-framework-react.FrameworkProvider | FrameworkProvider} to provide Fusion context.
49
- * - {@link @equinor/fusion-framework-react-module.ModuleProvider | ModuleProvider} to provide module instances.
50
- *
51
- * @template TModules The types of modules included in the configuration.
52
- * @template TRef The type of the Fusion instance.
53
- * @template TEnv The environment type for the application.
54
- * @param {React.ReactNode} Component - The React component to render lazily.
55
- * @param {Object} args - The arguments required for module configuration and component rendering.
56
- * @param {TRef} args.fusion - The Fusion instance to be used by the component and modules.
57
- * @param {TEnv} args.env - The environment context for the application.
58
- * @param {AppModuleInitiator<TModules, TRef, TEnv>} [configure] - Optional callback function for configuring application modules.
59
- * @returns {React.LazyExoticComponent<React.ComponentType>} A lazy component that, when rendered,
60
- * initializes the specified modules and provides the necessary Fusion and module context.
61
- */
62
- export const makeComponent = <
63
- TModules extends Array<AnyModule>,
64
- TRef extends Fusion = Fusion,
65
- TEnv extends AppEnv = AppEnv,
66
- >(
67
- Component: React.ReactNode,
68
- args: { fusion: TRef; env: TEnv },
69
- configure?: AppModuleInitiator<TModules, TRef, TEnv>,
70
- ): React.LazyExoticComponent<React.ComponentType> =>
71
- lazy(async () => {
72
- const init = configureModules<TModules, TRef, TEnv>(configure);
73
- const modules = await init(args);
74
-
75
- const { fusion } = args;
76
-
77
- modules.event.dispatchEvent('onReactAppLoaded', {
78
- detail: { modules, fusion, env: args.env },
79
- source: Component,
80
- });
81
-
82
- return {
83
- default: () => (
84
- <FrameworkProvider value={fusion}>
85
- <AppModuleProvider value={modules}>{Component}</AppModuleProvider>
86
- </FrameworkProvider>
87
- ),
88
- };
89
- });
90
-
91
- declare module '@equinor/fusion-framework-module-event' {
92
- interface FrameworkEventMap {
93
- onReactAppLoaded: FrameworkEvent<
94
- FrameworkEventInit<
95
- { modules: AppModulesInstance; fusion: Fusion; env: AppEnv },
96
- React.ComponentType
97
- >
98
- >;
99
- }
100
- }
101
-
102
- export default makeComponent;
package/src/msal/index.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * MSAL authentication sub-path entry-point.
3
- *
4
- * Provides React hooks for accessing MSAL-based authentication state
5
- * (current account, access tokens) from within a Fusion application.
6
- *
7
- * @remarks
8
- * Requires `@equinor/fusion-framework-module-msal` to be installed and
9
- * configured by the host/portal. Applications should **not** configure the
10
- * MSAL module themselves.
11
- *
12
- * @packageDocumentation
13
- */
14
- export { useCurrentAccount } from './useCurrentAccount';
15
- export { useAccessToken } from './useAccessToken';
16
- export { useToken } from './useToken';
@@ -1,26 +0,0 @@
1
- import { useToken } from './useToken';
2
-
3
- /**
4
- * React hook that acquires an OAuth 2.0 access token string via MSAL.
5
- *
6
- * This is a convenience wrapper around {@link useToken} that extracts the
7
- * `accessToken` property from the full `AuthenticationResult`.
8
- *
9
- * @param req - The token request containing the `scopes` to acquire.
10
- * @param req.scopes - Array of scope strings (e.g. `['User.Read']`).
11
- * @returns An object with:
12
- * - `token` – the access token string, or `undefined` while pending.
13
- * - `pending` – `true` while the token is being acquired.
14
- * - `error` – any error encountered during acquisition.
15
- *
16
- * @example
17
- * ```tsx
18
- * const { token, pending, error } = useAccessToken({ scopes: ['api://my-api/.default'] });
19
- * ```
20
- */
21
- export const useAccessToken = (req: {
22
- scopes: string[];
23
- }): { token?: string; pending: boolean; error: unknown } => {
24
- const { token, error, pending } = useToken(req);
25
- return { token: token?.accessToken, pending, error };
26
- };
@@ -1,21 +0,0 @@
1
- import type { AccountInfo } from '@equinor/fusion-framework-module-msal';
2
- import useAppModule from '../useAppModule';
3
-
4
- /**
5
- * React hook that returns the currently signed-in user's MSAL account info.
6
- *
7
- * @returns The {@link AccountInfo} for the active account, or `undefined` if
8
- * no user is signed in.
9
- *
10
- * @example
11
- * ```tsx
12
- * const account = useCurrentAccount();
13
- * if (account) {
14
- * console.log('Signed in as', account.name);
15
- * }
16
- * ```
17
- */
18
- export const useCurrentAccount = (): AccountInfo | undefined => {
19
- const msalProvider = useAppModule('auth');
20
- return msalProvider.account || undefined;
21
- };
@@ -1,52 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- import type { AuthenticationResult } from '@equinor/fusion-framework-module-msal';
4
-
5
- import useAppModule from '../useAppModule';
6
-
7
- /**
8
- * React hook that acquires a full MSAL {@link AuthenticationResult} for the
9
- * requested scopes.
10
- *
11
- * The hook attempts silent acquisition first and falls back to an interactive
12
- * prompt when required by the MSAL provider.
13
- *
14
- * @param req - The token request containing the `scopes` to acquire.
15
- * @param req.scopes - Array of scope strings (e.g. `['User.Read']`).
16
- * @returns An object with:
17
- * - `token` – the full {@link AuthenticationResult}, or `undefined` while pending.
18
- * - `pending` – `true` while the token is being acquired.
19
- * - `error` – any error encountered during acquisition.
20
- *
21
- * @example
22
- * ```tsx
23
- * const { token, pending } = useToken({ scopes: ['User.Read'] });
24
- * if (pending) return <Spinner />;
25
- * console.log('ID token:', token?.idToken);
26
- * ```
27
- */
28
- export const useToken = (req: {
29
- scopes: string[];
30
- }): { token?: AuthenticationResult; pending: boolean; error: unknown } => {
31
- const msalProvider = useAppModule('auth');
32
- const [token, setToken] = useState<AuthenticationResult | undefined>(undefined);
33
- const [pending, setPending] = useState<boolean>(false);
34
- const [error, setError] = useState<unknown>(null);
35
- useEffect(() => {
36
- setPending(true);
37
- setToken(undefined);
38
- msalProvider
39
- .acquireToken({ request: req })
40
- .then((result) => {
41
- // Only update state when a token was actually acquired
42
- if (result) {
43
- setToken(result);
44
- }
45
- })
46
- .catch(setError)
47
- .finally(() => setPending(false));
48
- }, [msalProvider, req]);
49
- return { token, pending, error };
50
- };
51
-
52
- export default useToken;
@@ -1,10 +0,0 @@
1
- /**
2
- * Navigation sub-path entry-point.
3
- *
4
- * Provides hooks for accessing the Fusion navigation module and creating
5
- * client-side routers compatible with `react-router`.
6
- *
7
- * @packageDocumentation
8
- */
9
- export { useNavigationModule } from './useNavigationModule';
10
- export { useRouter } from './useRouter';
@@ -1,10 +0,0 @@
1
- import useAppModule from '../useAppModule';
2
- import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
3
-
4
- /**
5
- * React hook that resolves the application-scoped navigation module provider.
6
- *
7
- * @returns The navigation provider instance.
8
- * @throws If the navigation module has not been enabled for the application.
9
- */
10
- export const useNavigationModule = (): INavigationProvider => useAppModule('navigation');
@@ -1,35 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { useNavigationModule } from './useNavigationModule';
3
- import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
4
-
5
- /**
6
- * React hook that creates a router instance for client-side navigation.
7
- *
8
- * The `routes` argument **must** be static or memoised to avoid re-creating
9
- * the router on every render.
10
- *
11
- * @param routes - An array of route objects compatible with
12
- * `INavigationProvider.createRouter`.
13
- * @returns A router instance to pass to `<RouterProvider>`.
14
- *
15
- * @see {@link https://equinor.github.io/fusion-framework/modules/navigation/ | Fusion navigation docs}
16
- * @see {@link https://reactrouter.com/en/main/routers/create-browser-router | react-router docs}
17
- *
18
- * @example
19
- * ```tsx
20
- * import { useRouter } from '@equinor/fusion-framework-react-app/navigation';
21
- * import { RouterProvider } from '@equinor/fusion-framework-react-router';
22
- *
23
- * const routes = [{ path: '/', element: <Home /> }];
24
- * const App = () => {
25
- * const router = useRouter(routes);
26
- * return <RouterProvider router={router} />;
27
- * };
28
- * ```
29
- */
30
- export const useRouter = (
31
- routes: Parameters<INavigationProvider['createRouter']>[0],
32
- ): ReturnType<INavigationProvider['createRouter']> => {
33
- const provider = useNavigationModule();
34
- return useMemo(() => provider.createRouter(routes), [provider, routes]);
35
- };
package/src/render-app.ts DELETED
@@ -1,35 +0,0 @@
1
- import { createComponent } from './create-component';
2
- import { renderComponent, type RenderTeardown } from './render-component';
3
-
4
- import type { ComponentRenderArgs } from './create-component';
5
-
6
- /**
7
- * Creates a render function for a Fusion React application.
8
- *
9
- * Wraps {@link createComponent} and {@link renderComponent} into a single factory:
10
- * call the returned function with an `HTMLElement` and `ComponentRenderArgs` to
11
- * mount the app using React 18's `createRoot` API.
12
- *
13
- * @param componentArgs - Arguments forwarded to {@link createComponent} (the React
14
- * component to render and an optional module-configuration callback).
15
- * @returns A mount function that accepts a DOM element and render args, and returns
16
- * a {@link RenderTeardown} callback to unmount the application.
17
- *
18
- * @example
19
- * ```ts
20
- * import { renderApp } from '@equinor/fusion-framework-react-app';
21
- * import { App } from './App';
22
- * import { configure } from './config';
23
- *
24
- * export const render = renderApp(App, configure);
25
- * export default render;
26
- * ```
27
- */
28
- export const renderApp = (...componentArgs: Parameters<typeof createComponent>) => {
29
- const renderer = renderComponent(createComponent(...componentArgs));
30
- return (el: HTMLElement, args: ComponentRenderArgs): RenderTeardown => {
31
- return renderer(el, args);
32
- };
33
- };
34
-
35
- export default renderApp;
@@ -1,55 +0,0 @@
1
- import { Suspense, StrictMode } from 'react';
2
- import type { FunctionComponent } from 'react';
3
- import { createRoot, type Root } from 'react-dom/client';
4
- import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
5
-
6
- /**
7
- * Callback returned after mounting an application; invoke it to unmount and clean
8
- * up the React root.
9
- */
10
- export type RenderTeardown = VoidFunction;
11
-
12
- /**
13
- * Renders a React component into a DOM element using React 18's `createRoot` API.
14
- *
15
- * The component is wrapped in `<StrictMode>` and `<Suspense>` with a basic
16
- * loading fallback.
17
- *
18
- * @param el - The DOM element to render into.
19
- * @param Component - The React function component to render.
20
- * @returns A {@link RenderTeardown} callback that unmounts the component.
21
- */
22
- const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
23
- const root: Root = createRoot(el);
24
- root.render(
25
- <StrictMode>
26
- <Suspense fallback={<p>loading app</p>}>
27
- <Component />
28
- </Suspense>
29
- </StrictMode>,
30
- );
31
- return () => {
32
- root.unmount();
33
- };
34
- };
35
-
36
- /**
37
- * Creates a mount function from a {@link ComponentRenderer}.
38
- *
39
- * The returned function accepts a target `HTMLElement` and
40
- * {@link ComponentRenderArgs}, resolves the lazy component via the renderer,
41
- * and mounts it with React 18's `createRoot`.
42
- *
43
- * @param renderer - A {@link ComponentRenderer} that produces a lazy component
44
- * from Fusion and environment arguments.
45
- * @returns A function `(el, args) => RenderTeardown` that mounts the app and
46
- * returns a teardown callback.
47
- */
48
- export const renderComponent = (renderer: ComponentRenderer) => {
49
- return (el: HTMLElement, args: ComponentRenderArgs): RenderTeardown => {
50
- const Component = renderer(args.fusion, args.env);
51
- return render(el, Component);
52
- };
53
- };
54
-
55
- export default renderComponent;
@@ -1,33 +0,0 @@
1
- /**
2
- * Routing sub-path entry-point for `@equinor/fusion-framework-react-app`.
3
- *
4
- * Re-exports the full public API of `@equinor/fusion-framework-react-router`
5
- * and its route builder DSL so consumers can import all routing primitives
6
- * from a single entry point without adding a separate direct dependency.
7
- *
8
- * Requires `@equinor/fusion-framework-react-router` to be installed.
9
- * It is declared as an optional peer dependency — install it only when
10
- * you need routing in your app, portal, or widget.
11
- *
12
- * @example
13
- * ```ts
14
- * import { Router } from '@equinor/fusion-framework-react-app/routing';
15
- * import { layout, index, route } from '@equinor/fusion-framework-react-app/routing';
16
- * ```
17
- *
18
- * @packageDocumentation
19
- */
20
- export * from '@equinor/fusion-framework-react-router';
21
- // Explicit re-exports from /routes so the DSL `Route` class takes precedence
22
- // over the deprecated react-router `Route` component from the main entry.
23
- export {
24
- index,
25
- IndexRoute,
26
- route,
27
- Route,
28
- layout,
29
- LayoutRoute,
30
- prefix,
31
- PrefixRoute,
32
- } from '@equinor/fusion-framework-react-router/routes';
33
- export type { RouteSchemaEntry } from '@equinor/fusion-framework-react-router/routes';