@equinor/fusion-framework-react-module-context 6.2.18-msal-6cf764b628c2afdd64dfd06e42abc953d78556d2 → 6.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -162
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/useCurrentContext.js.map +1 -1
- package/dist/esm/useQueryContext.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/useCurrentContext.d.ts +2 -2
- package/dist/types/useQueryContext.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +6 -6
- package/src/useCurrentContext.ts +20 -20
- package/src/useQueryContext.ts +10 -10
- package/src/version.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContextItem } from '@equinor/fusion-framework-module-context';
|
|
2
|
-
import { IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
1
|
+
import type { ContextItem } from '@equinor/fusion-framework-module-context';
|
|
2
|
+
import { type IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
3
3
|
export declare const useCurrentContext: (provider: IContextProvider) => {
|
|
4
4
|
currentContext: ContextItem | null | undefined;
|
|
5
5
|
setCurrentContext: (entry?: ContextItem | string | null) => void | Promise<ContextItem<Record<string, unknown>> | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
1
|
+
import { type IContextProvider } from '@equinor/fusion-framework-module-context';
|
|
2
2
|
export declare const useQueryContext: (provider: IContextProvider, options?: {
|
|
3
3
|
debounce?: number;
|
|
4
4
|
}) => {
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.2.
|
|
1
|
+
export declare const version = "6.2.18";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react-module-context",
|
|
3
|
-
"version": "6.2.18
|
|
3
|
+
"version": "6.2.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"directory": "packages/react/modules/context"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@equinor/fusion-framework-module-context": "^5.0.17
|
|
26
|
-
"@equinor/fusion-framework-react-module": "^3.1.7
|
|
27
|
-
"@equinor/fusion-
|
|
28
|
-
"@equinor/fusion-
|
|
25
|
+
"@equinor/fusion-framework-module-context": "^5.0.17",
|
|
26
|
+
"@equinor/fusion-framework-react-module": "^3.1.7",
|
|
27
|
+
"@equinor/fusion-observable": "^8.4.5",
|
|
28
|
+
"@equinor/fusion-query": "^5.2.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^18.2.50",
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
enableContext,
|
|
3
|
+
ContextModule,
|
|
4
|
+
ContextItem,
|
|
5
|
+
ContextItemType,
|
|
6
|
+
IContextProvider,
|
|
7
|
+
IContextModuleConfigurator,
|
|
8
8
|
} from '@equinor/fusion-framework-module-context';
|
|
9
9
|
export { FusionContextSearchError } from '@equinor/fusion-framework-module-context/errors.js';
|
|
10
10
|
|
package/src/useCurrentContext.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ContextItem, ContextModule } from '@equinor/fusion-framework-module-context';
|
|
2
|
-
import { IContextProvider, contextModuleKey } from '@equinor/fusion-framework-module-context';
|
|
1
|
+
import type { ContextItem, ContextModule } from '@equinor/fusion-framework-module-context';
|
|
2
|
+
import { type IContextProvider, contextModuleKey } from '@equinor/fusion-framework-module-context';
|
|
3
3
|
import { useModule } from '@equinor/fusion-framework-react-module';
|
|
4
4
|
import { useObservableState } from '@equinor/fusion-observable/react';
|
|
5
5
|
import { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
export const useCurrentContext = (provider: IContextProvider) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
const currentContext$ = useMemo(() => provider.currentContext$, [provider]);
|
|
9
|
+
const { value: currentContext } = useObservableState(currentContext$, {
|
|
10
|
+
initial: provider.currentContext,
|
|
11
|
+
});
|
|
12
|
+
const setCurrentContext = useCallback(
|
|
13
|
+
(entry?: ContextItem | string | null) => {
|
|
14
|
+
if (!entry) {
|
|
15
|
+
return provider.clearCurrentContext();
|
|
16
|
+
} else if (typeof entry === 'string') {
|
|
17
|
+
return provider.setCurrentContextByIdAsync(entry);
|
|
18
|
+
}
|
|
19
|
+
return provider.setCurrentContextAsync(entry);
|
|
20
|
+
},
|
|
21
|
+
[provider],
|
|
22
|
+
);
|
|
23
|
+
return { currentContext, setCurrentContext };
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* uses context provider from closes module provider
|
|
28
28
|
*/
|
|
29
29
|
export const useModuleCurrentContext = () => {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const provider = useModule<ContextModule>(contextModuleKey);
|
|
31
|
+
return useCurrentContext(provider);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export default useModuleCurrentContext;
|
package/src/useQueryContext.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type ContextModule,
|
|
3
|
+
contextModuleKey,
|
|
4
|
+
type IContextProvider,
|
|
5
5
|
} from '@equinor/fusion-framework-module-context';
|
|
6
6
|
import { useModule } from '@equinor/fusion-framework-react-module';
|
|
7
7
|
import { useObservableState, useDebounce } from '@equinor/fusion-observable/react';
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
9
|
|
|
10
10
|
export const useQueryContext = (provider: IContextProvider, options?: { debounce?: number }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const args = Object.assign({}, { debounce: 500 }, options);
|
|
12
|
+
const searchFn = useMemo(() => provider.queryContext.bind(provider), [provider]);
|
|
13
|
+
const { idle, next, value$ } = useDebounce(searchFn, args);
|
|
14
|
+
const { value } = useObservableState(value$);
|
|
15
|
+
return { value, querying: !idle, query: next };
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const useModuleQueryContext = (options?: { debounce?: number }) => {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const provider = useModule<ContextModule>(contextModuleKey);
|
|
20
|
+
return useQueryContext(provider, options);
|
|
21
21
|
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '6.2.
|
|
2
|
+
export const version = '6.2.18';
|