@trackunit/react-core-contexts 0.0.1-alpha-d61feec588.0 → 0.0.1-alpha-a2aba2c20d.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.
package/TrackunitProviders.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { TranslationResource } from "@trackunit/i18n-library-translation";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
interface
|
|
3
|
+
export interface TrackunitProvidersProps {
|
|
4
|
+
/** A translation resource for the App extensions to be registered before initialization */
|
|
5
|
+
translations?: TranslationResource<string>;
|
|
3
6
|
children: React.ReactNode;
|
|
4
7
|
}
|
|
5
|
-
export declare const TrackunitProviders: ({ children }:
|
|
6
|
-
export {};
|
|
8
|
+
export declare const TrackunitProviders: ({ translations, children }: TrackunitProvidersProps) => JSX.Element;
|
package/index.js
CHANGED
|
@@ -3,11 +3,14 @@ import { ApolloClient, InMemoryCache, from, split as split$1, ApolloProvider } f
|
|
|
3
3
|
import { setContext } from '@apollo/client/link/context';
|
|
4
4
|
import { onError } from '@apollo/client/link/error';
|
|
5
5
|
import * as Sentry from '@sentry/browser';
|
|
6
|
-
import { useEnvironment, useToken, ToastProvider, EnvironmentContextProvider, TokenProvider, CurrentUserProvider, UserSubscriptionProvider as UserSubscriptionProvider$1, useURLSynchronization } from '@trackunit/react-core-hooks';
|
|
6
|
+
import { useEnvironment, useToken, ToastProvider, AssetSortingProvider, EnvironmentContextProvider, GlobalSelectionProvider, TokenProvider, CurrentUserProvider, UserSubscriptionProvider as UserSubscriptionProvider$1, useURLSynchronization } from '@trackunit/react-core-hooks';
|
|
7
7
|
import { createUploadLink } from 'apollo-upload-client';
|
|
8
|
-
import { ToastRuntime, EnvironmentRuntime, TokenRuntime, CurrentUserRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
|
|
8
|
+
import { ToastRuntime, AssetSortingRuntime, EnvironmentRuntime, GlobalSelectionRuntime, TokenRuntime, CurrentUserRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import { useMemo } from 'react';
|
|
10
|
+
import { useMemo, useState, useEffect, useCallback } from 'react';
|
|
11
|
+
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
12
|
+
import { Spinner } from '@trackunit/react-components';
|
|
13
|
+
import { SortOrder } from '@trackunit/react-core-contexts-api';
|
|
11
14
|
import { BrowserRouter } from 'react-router-dom';
|
|
12
15
|
|
|
13
16
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -2444,6 +2447,40 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
2444
2447
|
|
|
2445
2448
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
2446
2449
|
|
|
2450
|
+
const TileAssetSortingProvider = ({
|
|
2451
|
+
children
|
|
2452
|
+
}) => {
|
|
2453
|
+
const [assetSortingState, setAssetSortingState] = useState(null);
|
|
2454
|
+
useEffect(() => {
|
|
2455
|
+
AssetSortingRuntime.getAssetSortingState().catch(() => null).then(setAssetSortingState);
|
|
2456
|
+
}, []);
|
|
2457
|
+
const setSortingState = useCallback((...args) => {
|
|
2458
|
+
// TODO when we can trigger a reload of the state from the host, remove this logic that updates the local state
|
|
2459
|
+
AssetSortingRuntime.setAssetSortingState(...args).then(() => {
|
|
2460
|
+
var _a;
|
|
2461
|
+
|
|
2462
|
+
setAssetSortingState({
|
|
2463
|
+
sortBy: args[0],
|
|
2464
|
+
order: (_a = args[1]) !== null && _a !== void 0 ? _a : SortOrder.Desc
|
|
2465
|
+
});
|
|
2466
|
+
});
|
|
2467
|
+
}, []);
|
|
2468
|
+
const contextValue = useMemo(() => ({
|
|
2469
|
+
sortingState: assetSortingState,
|
|
2470
|
+
setSortBy: setSortingState
|
|
2471
|
+
}), [assetSortingState, setSortingState]);
|
|
2472
|
+
|
|
2473
|
+
if (!assetSortingState) {
|
|
2474
|
+
return null;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
return jsx(AssetSortingProvider, Object.assign({
|
|
2478
|
+
value: contextValue
|
|
2479
|
+
}, {
|
|
2480
|
+
children: children
|
|
2481
|
+
}));
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2447
2484
|
const TileEnvironmentProvider = ({
|
|
2448
2485
|
children
|
|
2449
2486
|
}) => {
|
|
@@ -2473,6 +2510,25 @@ const TileEnvironmentProvider = ({
|
|
|
2473
2510
|
}));
|
|
2474
2511
|
};
|
|
2475
2512
|
|
|
2513
|
+
const TileGlobalSelectionProvider = ({
|
|
2514
|
+
children
|
|
2515
|
+
}) => {
|
|
2516
|
+
const [GlobalSelectionContext, setGlobalSelectionContext] = useState(null);
|
|
2517
|
+
useEffect(() => {
|
|
2518
|
+
GlobalSelectionRuntime.getGlobalSelection().catch(() => null).then(setGlobalSelectionContext);
|
|
2519
|
+
}, []);
|
|
2520
|
+
|
|
2521
|
+
if (!GlobalSelectionContext) {
|
|
2522
|
+
return null;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
return jsx(GlobalSelectionProvider, Object.assign({
|
|
2526
|
+
value: GlobalSelectionContext
|
|
2527
|
+
}, {
|
|
2528
|
+
children: children
|
|
2529
|
+
}));
|
|
2530
|
+
};
|
|
2531
|
+
|
|
2476
2532
|
const TileTokenProvider = ({
|
|
2477
2533
|
children
|
|
2478
2534
|
}) => {
|
|
@@ -2544,8 +2600,12 @@ const TrackunitDataProviders = ({
|
|
|
2544
2600
|
children: jsx(TileTokenProvider, {
|
|
2545
2601
|
children: jsx(TileCurrentUserProvider, {
|
|
2546
2602
|
children: jsx(UserSubscriptionProvider, {
|
|
2547
|
-
children: jsx(
|
|
2548
|
-
children:
|
|
2603
|
+
children: jsx(TileGlobalSelectionProvider, {
|
|
2604
|
+
children: jsx(TileAssetSortingProvider, {
|
|
2605
|
+
children: jsx(ManagerApolloProvider, {
|
|
2606
|
+
children: children
|
|
2607
|
+
})
|
|
2608
|
+
})
|
|
2549
2609
|
})
|
|
2550
2610
|
})
|
|
2551
2611
|
})
|
|
@@ -2580,13 +2640,28 @@ const TrackunitRouter = ({
|
|
|
2580
2640
|
};
|
|
2581
2641
|
|
|
2582
2642
|
const TrackunitProviders = ({
|
|
2643
|
+
translations,
|
|
2583
2644
|
children
|
|
2584
|
-
}) =>
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2645
|
+
}) => {
|
|
2646
|
+
if (translations) {
|
|
2647
|
+
registerTranslations(translations); // Register the apps translations if passed.
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
initializeTranslationsForApp(); // Initialize all registered translations
|
|
2651
|
+
|
|
2652
|
+
return jsx(TrackunitDataProviders, {
|
|
2653
|
+
children: jsx(ToastProviderApp, {
|
|
2654
|
+
children: jsx(React.Suspense, Object.assign({
|
|
2655
|
+
fallback: jsx(Spinner, {
|
|
2656
|
+
centered: true
|
|
2657
|
+
})
|
|
2658
|
+
}, {
|
|
2659
|
+
children: jsx(TrackunitRouter, {
|
|
2660
|
+
children: children
|
|
2661
|
+
})
|
|
2662
|
+
}))
|
|
2588
2663
|
})
|
|
2589
|
-
})
|
|
2590
|
-
}
|
|
2664
|
+
});
|
|
2665
|
+
};
|
|
2591
2666
|
|
|
2592
2667
|
export { ManagerApolloProvider, ToastProviderApp, TrackunitProviders };
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "0.0.1-alpha-
|
|
3
|
+
"version": "0.0.1-alpha-a2aba2c20d.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"graphql": "^15.8.0",
|
|
8
|
-
"@trackunit/iris-app-runtime-core": "0.0.1-alpha-
|
|
9
|
-
"@trackunit/react-core-contexts-api": "0.0.1-alpha-
|
|
10
|
-
"@trackunit/react-core-
|
|
8
|
+
"@trackunit/iris-app-runtime-core": "0.0.1-alpha-a2aba2c20d.0",
|
|
9
|
+
"@trackunit/react-core-contexts-api": "0.0.1-alpha-a2aba2c20d.0",
|
|
10
|
+
"@trackunit/react-core-contexts-test": "0.0.1-alpha-a2aba2c20d.0",
|
|
11
|
+
"@trackunit/react-core-hooks": "0.0.1-alpha-a2aba2c20d.0",
|
|
11
12
|
"react": "17.0.2",
|
|
12
|
-
"@trackunit/react-core-contexts-test": "0.0.1-alpha-d61feec588.0",
|
|
13
13
|
"@apollo/client": "3.6.9",
|
|
14
14
|
"@sentry/browser": "^7.15.0",
|
|
15
15
|
"apollo-upload-client": "^14.1.3",
|
|
16
|
+
"@trackunit/i18n-library-translation": "0.0.1-alpha-a2aba2c20d.0",
|
|
17
|
+
"@trackunit/react-components": "0.0.1-alpha-a2aba2c20d.0",
|
|
16
18
|
"react-router-dom": "6.4.1"
|
|
17
19
|
},
|
|
18
20
|
"module": "./index.js",
|