@equinor/fusion-framework-react-app 14.1.0 → 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 (93) hide show
  1. package/dist/esm/version.js +1 -1
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/dist/types/version.d.ts +1 -1
  4. package/package.json +33 -30
  5. package/CHANGELOG.md +0 -2785
  6. package/docs/ag-grid.md +0 -70
  7. package/docs/analytics.md +0 -122
  8. package/docs/app.md +0 -148
  9. package/docs/apploader.md +0 -110
  10. package/docs/bookmark.md +0 -108
  11. package/docs/context.md +0 -88
  12. package/docs/feature-flag.md +0 -119
  13. package/docs/framework.md +0 -93
  14. package/docs/help-center.md +0 -88
  15. package/docs/http.md +0 -118
  16. package/docs/msal.md +0 -291
  17. package/docs/navigation.md +0 -80
  18. package/docs/routing.md +0 -86
  19. package/docs/settings.md +0 -139
  20. package/src/__tests__/Apploader.test.tsx +0 -51
  21. package/src/__tests__/fixtures/apploader-child-script.ts +0 -9
  22. package/src/__tests__/render-app.test.tsx +0 -113
  23. package/src/__tests__/testApp.test.tsx +0 -76
  24. package/src/__tests__/useAccessToken.test.tsx +0 -51
  25. package/src/__tests__/useAppSetting.test.tsx +0 -133
  26. package/src/__tests__/useAppSettings.test.tsx +0 -147
  27. package/src/__tests__/useCurrentAccount.test.tsx +0 -32
  28. package/src/__tests__/useCurrentBookmark.test.tsx +0 -108
  29. package/src/__tests__/useCurrentContext.test.tsx +0 -72
  30. package/src/__tests__/useFeature.test.tsx +0 -104
  31. package/src/__tests__/useHelpCenter.test.tsx +0 -64
  32. package/src/__tests__/useStateSyncEvents.test.ts +0 -58
  33. package/src/__tests__/useToken.test.tsx +0 -71
  34. package/src/__tests__/useTrackFeature.test.tsx +0 -83
  35. package/src/ag-grid/community.ts +0 -11
  36. package/src/ag-grid/enterprise.ts +0 -11
  37. package/src/ag-grid/react.ts +0 -11
  38. package/src/ag-grid/testing.ts +0 -19
  39. package/src/ag-grid/theme.ts +0 -17
  40. package/src/ag-grid/useTheme.ts +0 -21
  41. package/src/analytics/README.md +0 -148
  42. package/src/analytics/index.ts +0 -9
  43. package/src/analytics/useTrackFeature.ts +0 -73
  44. package/src/apploader/Apploader.tsx +0 -50
  45. package/src/apploader/README.md +0 -81
  46. package/src/apploader/index.ts +0 -10
  47. package/src/apploader/useApploader.ts +0 -107
  48. package/src/bookmark/index.ts +0 -20
  49. package/src/bookmark/useBookmark.ts +0 -25
  50. package/src/bookmark/useCurrentBookmark.ts +0 -54
  51. package/src/context/index.ts +0 -14
  52. package/src/context/useContextProvider.ts +0 -12
  53. package/src/context/useCurrentContext.ts +0 -20
  54. package/src/create-component.tsx +0 -120
  55. package/src/create-legacy-app.tsx +0 -51
  56. package/src/feature-flag/README.md +0 -20
  57. package/src/feature-flag/enable-feature-flag.ts +0 -79
  58. package/src/feature-flag/index.ts +0 -17
  59. package/src/feature-flag/useFeature.ts +0 -90
  60. package/src/framework/index.ts +0 -14
  61. package/src/framework/useFrameworkCurrentContext.ts +0 -15
  62. package/src/help-center/README.md +0 -21
  63. package/src/help-center/event-name.ts +0 -1
  64. package/src/help-center/index.ts +0 -11
  65. package/src/help-center/useHelpCenter.ts +0 -162
  66. package/src/http/index.ts +0 -10
  67. package/src/http/selectors.ts +0 -9
  68. package/src/index.ts +0 -46
  69. package/src/make-component.tsx +0 -102
  70. package/src/msal/index.ts +0 -16
  71. package/src/msal/useAccessToken.ts +0 -26
  72. package/src/msal/useCurrentAccount.ts +0 -21
  73. package/src/msal/useToken.ts +0 -63
  74. package/src/navigation/index.ts +0 -10
  75. package/src/navigation/useNavigationModule.ts +0 -10
  76. package/src/navigation/useRouter.ts +0 -35
  77. package/src/render-app.ts +0 -35
  78. package/src/render-component.tsx +0 -55
  79. package/src/routing/index.ts +0 -33
  80. package/src/settings/README.md +0 -123
  81. package/src/settings/index.ts +0 -12
  82. package/src/settings/useAppSetting.ts +0 -113
  83. package/src/settings/useAppSettings.ts +0 -103
  84. package/src/settings/useAppSettingsStatus.ts +0 -52
  85. package/src/state/index.ts +0 -12
  86. package/src/state/useAppState.ts +0 -299
  87. package/src/state/useStateSyncEvents.ts +0 -59
  88. package/src/useAppEnvironmentVariables.ts +0 -59
  89. package/src/useAppModule.ts +0 -45
  90. package/src/useAppModules.ts +0 -21
  91. package/src/version.ts +0 -2
  92. package/tsconfig.json +0 -54
  93. package/vitest.config.ts +0 -9
@@ -1,148 +0,0 @@
1
- ## Analytics React Hooks
2
-
3
- React hooks for tracking application feature usage through the Fusion analytics module.
4
-
5
- These hooks are available from `@equinor/fusion-framework-react-app/analytics`. The analytics module is enabled and configured by the hosting portal, so **apps running inside a Fusion portal can use these hooks immediately without any setup**.
6
-
7
- ### Why track feature usage?
8
-
9
- Understanding how users interact with your application helps you make informed decisions about what to build, improve, or remove. Without usage data, you are guessing which features matter.
10
-
11
- Common reasons to add feature tracking:
12
-
13
- - **Measure adoption** — find out whether a newly released feature is actually being used, and by how many users across different contexts.
14
- - **Identify unused features** — discover features that can be simplified or removed, reducing maintenance cost and complexity.
15
- - **Understand user workflows** — see which paths users take through your application, revealing unexpected patterns or friction points.
16
- - **Support data-driven prioritisation** — back up roadmap discussions with real usage numbers instead of assumptions.
17
- - **Debug user-reported issues** — correlate analytics events with error reports to understand what the user was doing when something went wrong.
18
-
19
- ### When to use `useTrackFeature`
20
-
21
- Use `useTrackFeature` when you want to record a discrete user action or application milestone from a React component. Typical use cases include:
22
-
23
- | Use case | What to track | Example event name |
24
- |----------|---------------|-------------------|
25
- | Button or action clicks | User triggers a specific workflow | `'export-clicked'`, `'filter-applied'` |
26
- | Page or component views | A section of the app is displayed | `'dashboard-loaded'`, `'settings-opened'` |
27
- | Feature gate checks | A feature behind a flag is accessed | `'beta-feature-used'` |
28
- | Form submissions | A user completes a form or wizard step | `'report-submitted'`, `'wizard-step-3'` |
29
- | Error recovery actions | A user retries or dismisses an error | `'retry-clicked'`, `'error-dismissed'` |
30
- | Search and filtering | A user interacts with data exploration tools | `'search-executed'`, `'date-range-changed'` |
31
-
32
- > [!TIP]
33
- > You do not need to track every click. Focus on actions that answer a question about user behavior or feature value.
34
-
35
- ### useTrackFeature
36
-
37
- Returns a stable callback for tracking feature usage events. Each event automatically includes the current app key and active context as attributes, so downstream dashboards can group events by application and context without extra work.
38
-
39
- **Signature:**
40
-
41
- ```typescript
42
- function useTrackFeature(): (name: string, data?: AnyValueMap) => void;
43
- ```
44
-
45
- | Parameter | Type | Description |
46
- |-----------|------|-------------|
47
- | `name` | `string` | Name of the feature being tracked |
48
- | `data` | `AnyValueMap` (optional) | Additional key-value pairs to include with the event |
49
-
50
- #### Track a button click
51
-
52
- ```tsx
53
- import { useCallback } from 'react';
54
- import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
55
-
56
- const MyButton = () => {
57
- const trackFeature = useTrackFeature();
58
-
59
- const handleClick = useCallback(() => {
60
- trackFeature('button-clicked');
61
- }, [trackFeature]);
62
-
63
- return <button onClick={handleClick}>Click me</button>;
64
- };
65
- ```
66
-
67
- #### Track with additional data
68
-
69
- Pass a second argument to include custom attributes with the event:
70
-
71
- ```tsx
72
- import { useCallback } from 'react';
73
- import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
74
-
75
- const SaveButton = ({ section }: { section: string }) => {
76
- const trackFeature = useTrackFeature();
77
-
78
- const handleSave = useCallback(() => {
79
- trackFeature('save-clicked', { section, timestamp: Date.now() });
80
- }, [trackFeature, section]);
81
-
82
- return <button onClick={handleSave}>Save</button>;
83
- };
84
- ```
85
-
86
- #### Track on component mount
87
-
88
- Use `useEffect` to track when a component or page loads:
89
-
90
- ```tsx
91
- import { useEffect } from 'react';
92
- import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
93
-
94
- const Dashboard = () => {
95
- const trackFeature = useTrackFeature();
96
-
97
- useEffect(() => {
98
- trackFeature('dashboard-loaded');
99
- }, [trackFeature]);
100
-
101
- return <div>Dashboard content</div>;
102
- };
103
- ```
104
-
105
- #### Combine click and mount tracking
106
-
107
- ```tsx
108
- import { useCallback, useEffect } from 'react';
109
- import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
110
-
111
- const SomeComponent = () => {
112
- const trackFeature = useTrackFeature();
113
-
114
- useEffect(() => {
115
- trackFeature('SomeComponent loaded');
116
- trackFeature('some feature happened', { extra: 'data', foo: 'bar' });
117
- }, [trackFeature]);
118
-
119
- const handleOnClick = useCallback(() => {
120
- trackFeature('button-clicked');
121
- }, [trackFeature]);
122
-
123
- return <button onClick={handleOnClick}>Click me</button>;
124
- };
125
- ```
126
-
127
- ### Prerequisites
128
-
129
- The analytics module must be enabled for these hooks to work. **In most cases, no app-level configuration is needed** — the hosting Fusion portal already enables and configures analytics with the appropriate adapters and collectors. Your app inherits this automatically.
130
-
131
- If the module is not available (e.g. in a standalone or custom portal setup), `useTrackFeature` logs an exception via the telemetry provider instead of throwing, so your app will not crash.
132
-
133
- #### Custom or standalone setups
134
-
135
- If you are building a custom portal or running outside the standard Fusion portal, you need to enable the analytics module yourself:
136
-
137
- ```typescript
138
- import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
139
- import { ConsoleAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';
140
-
141
- const configure = (configurator) => {
142
- enableAnalytics(configurator, (builder) => {
143
- builder.setAdapter('console', async () => new ConsoleAnalyticsAdapter());
144
- });
145
- };
146
- ```
147
-
148
- See the [analytics module documentation](https://equinor.github.io/fusion-framework/modules/analytics/) for adapter and collector setup.
@@ -1,9 +0,0 @@
1
- /**
2
- * Analytics sub-path entry-point.
3
- *
4
- * Provides the {@link useTrackFeature} hook for tracking application-level
5
- * analytics events through the Fusion analytics module.
6
- *
7
- * @packageDocumentation
8
- */
9
- export { useTrackFeature } from './useTrackFeature';
@@ -1,73 +0,0 @@
1
- import { useFrameworkModule } from '@equinor/fusion-framework-react';
2
- import type { AppModule } from '@equinor/fusion-framework-module-app';
3
- import type { AnalyticsModule, AnyValueMap } from '@equinor/fusion-framework-module-analytics';
4
- import { useCallback } from 'react';
5
-
6
- /**
7
- * React hook that returns a callback for tracking application feature usage
8
- * via the Fusion analytics module.
9
- *
10
- * The tracked event includes the current app key and context (if available)
11
- * as attributes, enabling downstream analytics dashboards to group events
12
- * by application and context.
13
- *
14
- * @returns A `trackFeature` callback: `(name: string, data?: AnyValueMap) => void`.
15
- *
16
- * @example
17
- * ```tsx
18
- * const trackFeature = useTrackFeature();
19
- *
20
- * const handleClick = useCallback(() => {
21
- * trackFeature('button-click', { section: 'header' });
22
- * }, [trackFeature]);
23
- * ```
24
- */
25
- export const useTrackFeature = () => {
26
- const analyticsProvider = useFrameworkModule<AnalyticsModule>('analytics');
27
- const appProvider = useFrameworkModule<AppModule>('app');
28
- const contextProvider = useFrameworkModule('context');
29
- const telemetryProvider = useFrameworkModule('telemetry');
30
-
31
- /**
32
- * Tracks a analytics event.
33
- *
34
- * Can be used both in useCallback or useEffects - see README.md for examples.
35
- *
36
- * @param name - The feature to track
37
- * @param data - Optional map of additional key-value pairs to include with the analytics event
38
- */
39
- const trackFeature = useCallback(
40
- (name: string, data?: AnyValueMap) => {
41
- // Report to telemetry when analytics tracking is not available so the gap is visible
42
- if (!analyticsProvider) {
43
- telemetryProvider?.trackException({
44
- name: 'AnalyticsProviderNotFound',
45
- exception: new Error(`Analytics provider not found`),
46
- });
47
- }
48
-
49
- analyticsProvider?.trackAnalytic({
50
- name: 'app-feature',
51
- value: {
52
- feature: name,
53
- data,
54
- },
55
- attributes: {
56
- appKey: appProvider?.current?.appKey,
57
- context: contextProvider?.currentContext
58
- ? {
59
- id: contextProvider.currentContext.id,
60
- externalId: contextProvider.currentContext.externalId,
61
- title: contextProvider.currentContext.title,
62
- type: contextProvider.currentContext.type.id,
63
- source: contextProvider.currentContext.source,
64
- }
65
- : undefined,
66
- },
67
- });
68
- },
69
- [analyticsProvider, appProvider, contextProvider, telemetryProvider],
70
- );
71
-
72
- return trackFeature;
73
- };
@@ -1,50 +0,0 @@
1
- import { useEffect, useRef, type ReactElement } from 'react';
2
- import { useApploader } from './useApploader';
3
-
4
- export type ApploaderProps = {
5
- appKey: string;
6
- };
7
-
8
- /**
9
- * Apploader component
10
- *
11
- * Embeds a Fusion child application inside a parent Fusion application.
12
- * Handles loading and error states, and mounts the child app's DOM element into a container div.
13
- *
14
- * @param { ApploaderProps } props - The props for the component.
15
- * @param { string } props.appKey - The key of the Fusion app to load and mount.
16
- * @returns { ReactElement } The rendered component, which displays loading, error, or the embedded app.
17
- *
18
- * @example
19
- * <Apploader appKey="my-app" />
20
- */
21
- export const Apploader = ({ appKey }: ApploaderProps): ReactElement => {
22
- const refWrapp = useRef<HTMLDivElement | null>(null);
23
- const { loading, error, appRef } = useApploader({ appKey });
24
-
25
- useEffect(() => {
26
- // Wait until both the wrapper element and the loaded app element are available
27
- if (!refWrapp.current || !appRef.current) {
28
- return;
29
- }
30
-
31
- refWrapp.current.appendChild(appRef.current);
32
- }, [appRef.current]);
33
-
34
- // Show a loading placeholder while the app is being fetched and initialized
35
- if (loading) {
36
- return <div>Loading {appKey}</div>;
37
- }
38
- // Surface the load error instead of rendering the app
39
- if (error) {
40
- return (
41
- <div>
42
- Error loading {appKey}. Error: {error.message}
43
- </div>
44
- );
45
- }
46
-
47
- return <div ref={refWrapp} />;
48
- };
49
-
50
- export default Apploader;
@@ -1,81 +0,0 @@
1
- # `@equinor/fusion-framework-react-app/apploader`
2
-
3
- > [!NOTE]
4
- > This file is kept for legacy tooling. The canonical documentation is in [`packages/react/app/docs/apploader.md`](../../docs/apploader.md) and published via VuePress.
5
-
6
- [Apploader](#apploader) component and [useApploader](#useapploader) is intended to be used to embed Fusion applications inside other Fusion application.
7
-
8
- > [!WARNING]
9
- > `Apploader` is an experimental poc.
10
- >
11
- > The embedded application will likely have issues with routing, context and other framework functionality, so use with care.
12
- >
13
- > Should only be used to embed 'simple' applications like **PowerBI** and **PowerApps**.
14
-
15
- ## Apploader
16
-
17
- React component for embeding a Fusion child application inside a parent Fusion application.
18
-
19
- Handles loading and error states, and mounts the child app's DOM element into a container div.
20
-
21
- If you need to customise the error and loading messages, then use the hook ``useApploader`` and create your own component.
22
-
23
- ### Example usage
24
-
25
- ```typescript
26
- <Apploader appKey="my-app" />
27
- ```
28
-
29
- ## useApploader
30
-
31
- A React hook for dynamically loading and mounting a Fusion child app inside a parent Fusion app. Handles loading state, error reporting, and provides a reference to the mounted app’s DOM element.
32
-
33
- ### Signature
34
-
35
- ```typescript
36
- useApploader({ appKey }: { appKey: string }): {
37
- loading: boolean;
38
- error: Error | undefined;
39
- appRef: React.RefObject<HTMLDivElement | null>;
40
- }
41
- ```
42
-
43
- ### Parameters
44
-
45
- `appKey (string)`: The key of the Fusion app to load and mount.
46
-
47
- ### Returns
48
-
49
- - **loading** ``(boolean)``: true while the app is loading.
50
- - **error** ``(Error | undefined)``: Error object if loading fails, otherwise undefined.
51
- - **appRef** ``(React.RefObject<HTMLDivElement | null>)``: Ref to the DOM element where the child app is mounted.
52
-
53
- ### Usage Example
54
-
55
- ```typescript
56
- import React, { useEffect, useRef } from 'react';
57
- import { useApploader } from './useAppLoader';
58
-
59
- const MyAppLoader = ({ appKey }: { appKey: string }) => {
60
- const wrapperRef = useRef<HTMLDivElement | null>(null);
61
- const { loading, error, appRef } = useApploader({ appKey });
62
-
63
- useEffect(() => {
64
- if (wrapperRef.current && appRef.current) {
65
- wrapperRef.current.appendChild(appRef.current);
66
- }
67
- }, [appRef.current]);
68
-
69
- if (loading) return <div>Loading {appKey}...</div>;
70
- if (error) return <div>Error loading {appKey}: {error.message}</div>;
71
-
72
- return <div ref={wrapperRef} />;
73
- };
74
- ```
75
-
76
- ### Notes
77
-
78
- - The hook is designed to be used in a parent Fusion app context.
79
- - The returned appRef should be appended to a container element in your component.
80
- - Handles subscription and cleanup automatically.
81
- - Useful for micro-frontend scenarios where apps are loaded dynamically.
@@ -1,10 +0,0 @@
1
- /**
2
- * Apploader sub-path entry-point.
3
- *
4
- * Provides the {@link Apploader} component and {@link useApploader} hook
5
- * for embedding Fusion child applications inside a parent Fusion application.
6
- *
7
- * @packageDocumentation
8
- */
9
- export { Apploader, type ApploaderProps } from './Apploader';
10
- export { useApploader } from './useApploader';
@@ -1,107 +0,0 @@
1
- import { useEffect, useMemo, useRef, useState } from 'react';
2
-
3
- import { useFramework } from '@equinor/fusion-framework-react';
4
- import type { AppModule } from '@equinor/fusion-framework-module-app';
5
-
6
- import type { ApploaderProps } from './Apploader';
7
- import type { AppInitializeResult } from '@equinor/fusion-framework-module-app/app';
8
-
9
- /**
10
- * React hook for dynamically loading and mounting a Fusion child app inside a parent Fusion app.
11
- * Handles loading state, error reporting, and provides a reference to the mounted app’s DOM element.
12
- *
13
- * @param { Object } params
14
- * @param { string } params.appKey - The key of the Fusion app to load and mount.
15
- * @returns {{
16
- * loading: boolean,
17
- * error: Error | undefined,
18
- * appRef: React.RefObject<HTMLDivElement | null>
19
- * }} An object containing loading state, error, and a ref to the mounted app element.
20
- *
21
- * @example
22
- * ```typescript
23
- * const { loading, error, appRef } = useApploader({ appKey: 'my-app' });
24
- *
25
- * useEffect(() => {
26
- * if (containerRef.current && appRef.current) {
27
- * containerRef.current.appendChild(appRef.current);
28
- * }
29
- * }, [appRef.current]);
30
- *
31
- * if (loading) return <div>Loading...</div>;
32
- * if (error) return <div>Error: {error.message}</div>;
33
- * return <div ref={containerRef} />;
34
- * ```
35
- */
36
- export const useApploader = ({
37
- appKey,
38
- }: ApploaderProps): {
39
- loading: boolean;
40
- error: Error | undefined;
41
- appRef: React.RefObject<HTMLDivElement | null>;
42
- } => {
43
- const [loading, setLoading] = useState(true);
44
- const [error, setError] = useState<Error | undefined>();
45
- const appRef = useRef<HTMLDivElement | null>(null);
46
- const fusion = useFramework<[AppModule]>();
47
-
48
- /**
49
- * The current fusion app.
50
- * aka the parent app that is loading the child app.
51
- */
52
- const fusionApp = useMemo(() => fusion.modules.app.current, [fusion]);
53
-
54
- /**
55
- * The app to be mounted
56
- * aka the child app that is being loaded.
57
- */
58
- const loadedApp = useMemo(() => fusion.modules.app.createApp({ appKey }), [fusion, appKey]);
59
-
60
- useEffect(() => {
61
- setLoading(true);
62
- setError(undefined);
63
- const subscription$ = loadedApp?.initialize().subscribe({
64
- next: (instance: AppInitializeResult) => {
65
- const { manifest, script, config } = instance;
66
- /* Application Element for mounting */
67
- appRef.current = document.createElement('div');
68
- appRef.current.id = manifest.appKey;
69
- appRef.current.style.display = 'contents';
70
-
71
- /* Use basename of current fusionApp */
72
- const basename = `/apps/${fusionApp?.appKey}`;
73
-
74
- try {
75
- const render = script.renderApp ?? script.default;
76
- // Prefer the modern renderApp export, falling back to the default export
77
- if (render) {
78
- return render(appRef.current, {
79
- fusion,
80
- env: { basename, config, manifest, props: {} },
81
- });
82
- }
83
- throw Error('Application is not supported, no render function provided');
84
- } catch (error) {
85
- console.error('App loading Error: ', error);
86
- setError(error as Error);
87
- }
88
- },
89
- complete: () => {
90
- setLoading(false);
91
- },
92
- error: (error: Error) => {
93
- setError(error);
94
- setLoading(false);
95
- },
96
- });
97
- return () => {
98
- subscription$.unsubscribe();
99
- };
100
- }, [fusionApp, loadedApp, fusion]);
101
-
102
- return {
103
- loading,
104
- error,
105
- appRef,
106
- };
107
- };
@@ -1,20 +0,0 @@
1
- /**
2
- * Bookmark sub-path entry-point.
3
- *
4
- * Provides helpers to enable and consume the Fusion bookmark module,
5
- * allowing users to save and restore application state snapshots.
6
- *
7
- * @packageDocumentation
8
- */
9
- export { enableBookmark } from '@equinor/fusion-framework-app/enable-bookmark';
10
-
11
- export { useCurrentBookmark } from './useCurrentBookmark';
12
- export { useBookmark } from './useBookmark';
13
-
14
- export type {
15
- Bookmark,
16
- Bookmarks,
17
- BookmarkData,
18
- BookmarkPayloadGenerator,
19
- BookmarkProvider,
20
- } from '@equinor/fusion-framework-react-module-bookmark';
@@ -1,25 +0,0 @@
1
- import {
2
- useBookmark as _useBookmark,
3
- type useBookmarkResult,
4
- } from '@equinor/fusion-framework-react-module-bookmark';
5
-
6
- /**
7
- * @deprecated Use useBookmark from @equinor/fusion-framework-react-module-bookmark
8
- * For application development the useCurrentBookmark should be sufficient enough
9
- *
10
- * Functionality provided here is:
11
- * - addBookmarkCreator
12
- * - getAllBookmarks
13
- * - createBookmark
14
- * - updateBookmark
15
- * - deleteBookmarkById
16
- * - setCurrentBookmark
17
- * - currentBookmark
18
- * - bookmarks,
19
- *
20
- * @template TData - Current applications bookmark type
21
- * @return {*} {Bookmarks<TData>} the full api fro handling bookmarks
22
- */
23
- export const useBookmark = <_TData>(): useBookmarkResult => _useBookmark();
24
-
25
- export default useBookmark;
@@ -1,54 +0,0 @@
1
- import {
2
- type BookmarkData,
3
- type BookmarkPayloadGenerator,
4
- type useCurrentBookmarkReturn,
5
- useCurrentBookmark as _useCurrentBookmark,
6
- type BookmarkModule,
7
- bookmarkWithDataSchema,
8
- } from '@equinor/fusion-framework-react-module-bookmark';
9
-
10
- import { useFrameworkModule } from '@equinor/fusion-framework-react';
11
- import useAppModules from '../useAppModules';
12
- import { useCurrentApp } from '@equinor/fusion-framework-react/app';
13
-
14
- /**
15
- * By providing a CreateBookMarkFn bookmarks is enabled for the current application.
16
- *
17
- * @template TData - Type of data stored in bookmark
18
- * @param {CreateBookMarkFn<TData>} [createBookmarkState] - Function for creating bookmark payload, this function should be wrapped in useCallback
19
- *
20
- * ```TS
21
- * // Example
22
- * const { currentBookmark } = useCurrentBookmark(useCallback(()=> someState, [someState]))
23
- * ```
24
- * @return {*} {CurrentBookmark<TData>}
25
- */
26
- export const useCurrentBookmark = <TData extends BookmarkData>(
27
- payloadGenerator?: BookmarkPayloadGenerator<TData>,
28
- ): useCurrentBookmarkReturn<TData> => {
29
- const { currentApp } = useCurrentApp();
30
- const appBookmarkProvider = useAppModules<[BookmarkModule]>().bookmark;
31
- const frameworkBookmarkProvider = useFrameworkModule<BookmarkModule>('bookmark');
32
- // Warn about the deprecated fallback to the framework-scoped bookmark provider
33
- if (!appBookmarkProvider) {
34
- console.warn(
35
- '@deprecation',
36
- 'application has not enabled bookmarks, this will not work in the future',
37
- );
38
- }
39
- const { currentBookmark, setCurrentBookmark } = _useCurrentBookmark<TData>({
40
- provider: appBookmarkProvider ?? frameworkBookmarkProvider,
41
- payloadGenerator,
42
- });
43
-
44
- const currentBookmarkAppKey = bookmarkWithDataSchema().safeParse(currentBookmark).success
45
- ? bookmarkWithDataSchema().parse(currentBookmark).appKey
46
- : null;
47
-
48
- return {
49
- currentBookmark: currentBookmarkAppKey === currentApp?.appKey ? currentBookmark : null,
50
- setCurrentBookmark,
51
- };
52
- };
53
-
54
- export default useCurrentBookmark;
@@ -1,14 +0,0 @@
1
- /**
2
- * Context sub-path entry-point.
3
- *
4
- * Provides hooks for reading and interacting with the Fusion context
5
- * (project, facility, etc.) at both the application and framework level.
6
- *
7
- * @packageDocumentation
8
- */
9
- export * from '@equinor/fusion-framework-react-module-context';
10
-
11
- export { useContextProvider } from './useContextProvider';
12
- export { useCurrentContext } from './useCurrentContext';
13
-
14
- export { useFrameworkCurrentContext } from '../framework/useFrameworkCurrentContext';
@@ -1,12 +0,0 @@
1
- import type { ContextModule } from '@equinor/fusion-framework-react-module-context';
2
- import { useAppModule } from '../useAppModule';
3
-
4
- /**
5
- * React hook that resolves the application-scoped context module provider.
6
- *
7
- * @returns The context module provider instance.
8
- * @throws If the context module is not registered in the application scope.
9
- */
10
- export const useContextProvider = () => useAppModule<ContextModule>('context');
11
-
12
- export default useContextProvider;
@@ -1,20 +0,0 @@
1
- import { useCurrentContext as _useCurrentContext } from '@equinor/fusion-framework-react-module-context';
2
- import useContextProvider from './useContextProvider';
3
-
4
- /**
5
- * React hook that returns the currently selected Fusion context from the
6
- * **application-scoped** context module.
7
- *
8
- * @returns The current context object, or `undefined` if no context is selected.
9
- *
10
- * @example
11
- * ```tsx
12
- * const context = useCurrentContext();
13
- * if (context) {
14
- * console.log('Selected:', context.title);
15
- * }
16
- * ```
17
- */
18
- export const useCurrentContext = () => _useCurrentContext(useContextProvider());
19
-
20
- export default useCurrentContext;