@trackunit/react-core-hooks 0.2.50 → 0.2.52
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/index.cjs +18 -2
- package/index.js +16 -3
- package/package.json +4 -4
- package/src/analytics/AnalyticsProvider.d.ts +8 -0
- package/src/assetSorting/AssetSortingProvider.d.ts +1 -6
- package/src/index.d.ts +1 -0
package/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
var React = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
|
|
8
8
|
var reactRouterDom = require('react-router-dom');
|
|
9
9
|
|
|
@@ -30,11 +30,24 @@ function _interopNamespace(e) {
|
|
|
30
30
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
31
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
32
32
|
|
|
33
|
+
const AnalyticsContext = React.createContext(null);
|
|
34
|
+
const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
|
|
35
|
+
/**
|
|
36
|
+
* Hook to get the analytics context.
|
|
37
|
+
*/
|
|
38
|
+
const useAnalytics = (type) => {
|
|
39
|
+
const context = React.useContext(AnalyticsContext);
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error("useAnalytics must be used within an AnalyticsProvider");
|
|
42
|
+
}
|
|
43
|
+
return context;
|
|
44
|
+
};
|
|
45
|
+
|
|
33
46
|
const AssetSortingContext = React.createContext(null);
|
|
34
47
|
/**
|
|
35
48
|
* This is a provider for the AssetSortingContext.
|
|
36
49
|
*/
|
|
37
|
-
const AssetSortingProvider =
|
|
50
|
+
const AssetSortingProvider = AssetSortingContext.Provider;
|
|
38
51
|
/**
|
|
39
52
|
* This is a hook to use the AssetSortingContext.
|
|
40
53
|
*/
|
|
@@ -288,6 +301,8 @@ const useCurrentUser = () => {
|
|
|
288
301
|
return context;
|
|
289
302
|
};
|
|
290
303
|
|
|
304
|
+
exports.AnalyticsContext = AnalyticsContext;
|
|
305
|
+
exports.AnalyticsContextProvider = AnalyticsContextProvider;
|
|
291
306
|
exports.AssetSortingProvider = AssetSortingProvider;
|
|
292
307
|
exports.CurrentUserProvider = CurrentUserProvider;
|
|
293
308
|
exports.EnvironmentContextProvider = EnvironmentContextProvider;
|
|
@@ -295,6 +310,7 @@ exports.GlobalSelectionProvider = GlobalSelectionProvider;
|
|
|
295
310
|
exports.ToastProvider = ToastProvider;
|
|
296
311
|
exports.TokenProvider = TokenProvider;
|
|
297
312
|
exports.UserSubscriptionProvider = UserSubscriptionProvider;
|
|
313
|
+
exports.useAnalytics = useAnalytics;
|
|
298
314
|
exports.useAssetRuntime = useAssetRuntime;
|
|
299
315
|
exports.useAssetSorting = useAssetSorting;
|
|
300
316
|
exports.useCurrentUser = useCurrentUser;
|
package/index.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import React__default, { createContext, useContext, useState, useEffect } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { NavigationRuntime, AssetRuntime, CustomFieldRuntime, RestRuntime, SiteRuntime } from '@trackunit/iris-app-runtime-core';
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
6
6
|
|
|
7
|
+
const AnalyticsContext = createContext(null);
|
|
8
|
+
const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
|
|
9
|
+
/**
|
|
10
|
+
* Hook to get the analytics context.
|
|
11
|
+
*/
|
|
12
|
+
const useAnalytics = (type) => {
|
|
13
|
+
const context = useContext(AnalyticsContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error("useAnalytics must be used within an AnalyticsProvider");
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
|
|
7
20
|
const AssetSortingContext = createContext(null);
|
|
8
21
|
/**
|
|
9
22
|
* This is a provider for the AssetSortingContext.
|
|
10
23
|
*/
|
|
11
|
-
const AssetSortingProvider =
|
|
24
|
+
const AssetSortingProvider = AssetSortingContext.Provider;
|
|
12
25
|
/**
|
|
13
26
|
* This is a hook to use the AssetSortingContext.
|
|
14
27
|
*/
|
|
@@ -262,4 +275,4 @@ const useCurrentUser = () => {
|
|
|
262
275
|
return context;
|
|
263
276
|
};
|
|
264
277
|
|
|
265
|
-
export { AssetSortingProvider, CurrentUserProvider, EnvironmentContextProvider, GlobalSelectionProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAssetRuntime, useAssetSorting, useCurrentUser, useCustomFieldRuntime, useCustomFieldRuntimeForEntity, useEnvironment, useGlobalSelection, useNavigationRuntime, useRestRuntime, useSiteRuntime, useToast, useToken, useURLSynchronization, useUserSubscription };
|
|
278
|
+
export { AnalyticsContext, AnalyticsContextProvider, AssetSortingProvider, CurrentUserProvider, EnvironmentContextProvider, GlobalSelectionProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAnalytics, useAssetRuntime, useAssetSorting, useCurrentUser, useCustomFieldRuntime, useCustomFieldRuntimeForEntity, useEnvironment, useGlobalSelection, useNavigationRuntime, useRestRuntime, useSiteRuntime, useToast, useToken, useURLSynchronization, useUserSubscription };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-hooks",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.52",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@trackunit/iris-app-runtime-core": "0.3.
|
|
12
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.
|
|
13
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
11
|
+
"@trackunit/iris-app-runtime-core": "0.3.39",
|
|
12
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.33",
|
|
13
|
+
"@trackunit/react-core-contexts-api": "0.2.30",
|
|
14
14
|
"react": "18.2.0",
|
|
15
15
|
"react-router-dom": "6.4.5"
|
|
16
16
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseEvent, Event, IAnalyticsContext, UnspecifiedEvent } from "@trackunit/react-core-contexts-api";
|
|
3
|
+
export declare const AnalyticsContext: import("react").Context<IAnalyticsContext<{}> | null>;
|
|
4
|
+
export declare const AnalyticsContextProvider: import("react").Provider<IAnalyticsContext<{}> | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Hook to get the analytics context.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useAnalytics: <T extends Record<string, Event<BaseEvent | UnspecifiedEvent>>>(type: T) => IAnalyticsContext<T>;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IAssetSortingContext } from "@trackunit/react-core-contexts-api";
|
|
3
|
-
interface Props {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
value: IAssetSortingContext;
|
|
6
|
-
}
|
|
7
3
|
/**
|
|
8
4
|
* This is a provider for the AssetSortingContext.
|
|
9
5
|
*/
|
|
10
|
-
export declare const AssetSortingProvider: (
|
|
6
|
+
export declare const AssetSortingProvider: import("react").Provider<IAssetSortingContext | null>;
|
|
11
7
|
/**
|
|
12
8
|
* This is a hook to use the AssetSortingContext.
|
|
13
9
|
*/
|
|
14
10
|
export declare const useAssetSorting: () => IAssetSortingContext;
|
|
15
|
-
export {};
|
package/src/index.d.ts
CHANGED