@trackunit/react-core-hooks 0.0.35 → 0.0.39

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/README.md CHANGED
@@ -1,5 +1,11 @@
1
- This is the documentation for library
1
+ # Trackunit React Core Hooks
2
+ The `@trackunit/react-core-hooks` package is a small package containing the core hooks used for getting data from our context providers inside Trackunit Iris Apps.
2
3
 
3
- # react-core-hooks
4
+ Trackunit Iris Apps are used by external developers to integrate custom functionality into [the Trackunit Manager platform](https://www.trackunit.com/services/manager/).
4
5
 
5
- The purpose of this library is to contain the core hooks used for getting data from our context providers.
6
+ For a full guide on Iris App Development, please visit our [Developer Hub](https://developers.trackunit.com/)
7
+ ## Trackunit
8
+ This package was developed by Trackunit ApS.
9
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
10
+
11
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { IEnvironmentContext } from "@trackunit/react-core-contexts-api";
3
+ interface IProps {
4
+ value: IEnvironmentContext;
5
+ children?: React.ReactNode;
6
+ }
7
+ export declare const EnvironmentContextProvider: (props: IProps) => JSX.Element;
8
+ export declare const useEnvironment: () => IEnvironmentContext;
9
+ export {};
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./environment/useEnvironment";
1
+ export * from "./environment/EnvironmentContextProvider";
2
2
  export * from "./subscription/UserSubscriptionProvider";
3
3
  export * from "./token/TokenProvider";
4
4
  export * from "./user/CurrentUserProvider";
package/index.js CHANGED
@@ -1,17 +1,6 @@
1
- import * as React from 'react';
2
- import { createContext, useContext } from 'react';
3
1
  import { jsx } from 'react/jsx-runtime';
4
-
5
- const EnvironmentContext = /*#__PURE__*/createContext(null);
6
- const useEnvironment = () => {
7
- const context = useContext(EnvironmentContext);
8
-
9
- if (!context) {
10
- throw new Error("useEnvironment must be used within an EnvironmentContext");
11
- }
12
-
13
- return context;
14
- };
2
+ import * as React from 'react';
3
+ import { useContext, createContext } from 'react';
15
4
 
16
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
6
 
@@ -1041,6 +1030,20 @@ $({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
1041
1030
  assign: assign
1042
1031
  });
1043
1032
 
1033
+ const EnvironmentContext = /*#__PURE__*/createContext(null);
1034
+ const EnvironmentContextProvider = props => {
1035
+ return jsx(EnvironmentContext.Provider, Object.assign({}, props));
1036
+ };
1037
+ const useEnvironment = () => {
1038
+ const context = useContext(EnvironmentContext);
1039
+
1040
+ if (!context) {
1041
+ throw new Error("useEnvironment must be used within an EnvironmentContext");
1042
+ }
1043
+
1044
+ return context;
1045
+ };
1046
+
1044
1047
  const UserSubscriptionContext = /*#__PURE__*/React.createContext(null);
1045
1048
  const UserSubscriptionProvider = props => {
1046
1049
  return jsx(UserSubscriptionContext.Provider, Object.assign({}, props));
@@ -1083,4 +1086,4 @@ const useCurrentUser = () => {
1083
1086
  return context;
1084
1087
  };
1085
1088
 
1086
- export { CurrentUserProvider, EnvironmentContext, TokenProvider, UserSubscriptionProvider, useCurrentUser, useEnvironment, useToken, useUserSubscription };
1089
+ export { CurrentUserProvider, EnvironmentContextProvider, TokenProvider, UserSubscriptionProvider, useCurrentUser, useEnvironment, useToken, useUserSubscription };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-hooks",
3
- "version": "0.0.35",
3
+ "version": "0.0.39",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "MIT",
6
6
  "module": "./index.js",
@@ -8,7 +8,7 @@
8
8
  "type": "module",
9
9
  "types": "./index.d.ts",
10
10
  "dependencies": {
11
- "@trackunit/react-core-contexts-api": "0.0.35",
11
+ "@trackunit/react-core-contexts-api": "0.0.38",
12
12
  "react": "17.0.1"
13
13
  },
14
14
  "peerDependencies": {}
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { IEnvironmentContext } from "@trackunit/react-core-contexts-api";
3
- export declare const EnvironmentContext: import("react").Context<IEnvironmentContext | null>;
4
- export declare const useEnvironment: () => IEnvironmentContext;