@trackunit/react-core-hooks 0.2.35-alpha-beca370860.0 → 0.2.38
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 +48 -0
- package/index.js +48 -0
- package/package.json +5 -4
- package/src/assetSorting/AssetSortingProvider.d.ts +6 -0
- package/src/developerSettings/DeveloperSettingsProvider.d.ts +6 -0
- package/src/environment/EnvironmentContextProvider.d.ts +6 -0
- package/src/global-selection/GlobalSelectionProvider.d.ts +6 -0
- package/src/runtimes/useCustomFieldRuntimeForEntity.d.ts +13 -0
- package/src/subscription/UserSubscriptionProvider.d.ts +6 -0
- package/src/toast/ToastProvider.d.ts +6 -0
- package/src/token/TokenProvider.d.ts +6 -0
- package/src/user/CurrentUserProvider.d.ts +6 -0
package/index.cjs
CHANGED
|
@@ -31,7 +31,13 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
31
31
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
32
32
|
|
|
33
33
|
const AssetSortingContext = React.createContext(null);
|
|
34
|
+
/**
|
|
35
|
+
* This is a provider for the AssetSortingContext.
|
|
36
|
+
*/
|
|
34
37
|
const AssetSortingProvider = (props) => jsxRuntime.jsx(AssetSortingContext.Provider, Object.assign({}, props));
|
|
38
|
+
/**
|
|
39
|
+
* This is a hook to use the AssetSortingContext.
|
|
40
|
+
*/
|
|
35
41
|
const useAssetSorting = () => {
|
|
36
42
|
const context = React.useContext(AssetSortingContext);
|
|
37
43
|
if (!context) {
|
|
@@ -43,6 +49,9 @@ const useAssetSorting = () => {
|
|
|
43
49
|
const DeveloperSettingsContext = React__namespace.createContext({
|
|
44
50
|
localFeatureFlagsEnabled: false,
|
|
45
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* This is a hook to use the DeveloperSettingsContext.
|
|
54
|
+
*/
|
|
46
55
|
const useDeveloperSettings = () => {
|
|
47
56
|
const context = React__namespace.useContext(DeveloperSettingsContext);
|
|
48
57
|
if (!context) {
|
|
@@ -50,6 +59,9 @@ const useDeveloperSettings = () => {
|
|
|
50
59
|
}
|
|
51
60
|
return context;
|
|
52
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* This is the provider for Developer Settings
|
|
64
|
+
*/
|
|
53
65
|
const DeveloperSettingsProvider = ({ value, children }) => {
|
|
54
66
|
const [localFeatureFlagsEnabled, setLocalFeatureFlagsEnabled] = React__namespace.useState(false);
|
|
55
67
|
const [localFeatureFlags, setLocalFeatureFlags] = React__namespace.useState();
|
|
@@ -67,9 +79,15 @@ const DeveloperSettingsProvider = ({ value, children }) => {
|
|
|
67
79
|
};
|
|
68
80
|
|
|
69
81
|
const EnvironmentContext = React.createContext(null);
|
|
82
|
+
/**
|
|
83
|
+
* This is a provider for the EnvironmentContext.
|
|
84
|
+
*/
|
|
70
85
|
const EnvironmentContextProvider = (props) => {
|
|
71
86
|
return jsxRuntime.jsx(EnvironmentContext.Provider, Object.assign({}, props));
|
|
72
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* This is a hook to use the EnvironmentContext.
|
|
90
|
+
*/
|
|
73
91
|
const useEnvironment = () => {
|
|
74
92
|
const context = React.useContext(EnvironmentContext);
|
|
75
93
|
if (!context) {
|
|
@@ -79,6 +97,9 @@ const useEnvironment = () => {
|
|
|
79
97
|
};
|
|
80
98
|
|
|
81
99
|
const GlobalSelectionContext = React__namespace.createContext(null);
|
|
100
|
+
/**
|
|
101
|
+
* This is a hook to use the GlobalSelectionContext.
|
|
102
|
+
*/
|
|
82
103
|
const useGlobalSelection = () => {
|
|
83
104
|
const context = React__namespace.useContext(GlobalSelectionContext);
|
|
84
105
|
if (!context) {
|
|
@@ -86,6 +107,9 @@ const useGlobalSelection = () => {
|
|
|
86
107
|
}
|
|
87
108
|
return context;
|
|
88
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* This is a provider for the GlobalSelectionContext.
|
|
112
|
+
*/
|
|
89
113
|
const GlobalSelectionProvider = (props) => jsxRuntime.jsx(GlobalSelectionContext.Provider, Object.assign({}, props));
|
|
90
114
|
|
|
91
115
|
/**
|
|
@@ -191,9 +215,15 @@ const useSiteRuntime = () => {
|
|
|
191
215
|
};
|
|
192
216
|
|
|
193
217
|
const UserSubscriptionContext = React__namespace.createContext(null);
|
|
218
|
+
/**
|
|
219
|
+
* This is a provider for the UserSubscriptionContext.
|
|
220
|
+
*/
|
|
194
221
|
const UserSubscriptionProvider = (props) => {
|
|
195
222
|
return jsxRuntime.jsx(UserSubscriptionContext.Provider, Object.assign({}, props));
|
|
196
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* This is a hook to use the UserSubscriptionContext.
|
|
226
|
+
*/
|
|
197
227
|
const useUserSubscription = () => {
|
|
198
228
|
const context = React__namespace.useContext(UserSubscriptionContext);
|
|
199
229
|
if (!context) {
|
|
@@ -203,7 +233,13 @@ const useUserSubscription = () => {
|
|
|
203
233
|
};
|
|
204
234
|
|
|
205
235
|
const ToastContext = React__namespace.createContext(null);
|
|
236
|
+
/**
|
|
237
|
+
* This is a provider for the ToastContext.
|
|
238
|
+
*/
|
|
206
239
|
const ToastProvider = (props) => jsxRuntime.jsx(ToastContext.Provider, Object.assign({}, props));
|
|
240
|
+
/**
|
|
241
|
+
* This is a hook to use the ToastContext.
|
|
242
|
+
*/
|
|
207
243
|
const useToast = () => {
|
|
208
244
|
const toastContext = React__namespace.useContext(ToastContext);
|
|
209
245
|
if (!toastContext) {
|
|
@@ -213,6 +249,9 @@ const useToast = () => {
|
|
|
213
249
|
};
|
|
214
250
|
|
|
215
251
|
const TokenContext = React__namespace.createContext(null);
|
|
252
|
+
/**
|
|
253
|
+
* This is a hook to use the TokenContext.
|
|
254
|
+
*/
|
|
216
255
|
const useToken = () => {
|
|
217
256
|
const context = React__namespace.useContext(TokenContext);
|
|
218
257
|
if (!context) {
|
|
@@ -220,14 +259,23 @@ const useToken = () => {
|
|
|
220
259
|
}
|
|
221
260
|
return context;
|
|
222
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* This is a provider for the TokenContext.
|
|
264
|
+
*/
|
|
223
265
|
const TokenProvider = (props) => {
|
|
224
266
|
return jsxRuntime.jsx(TokenContext.Provider, Object.assign({}, props));
|
|
225
267
|
};
|
|
226
268
|
|
|
227
269
|
const CurrentUserContext = React__namespace.createContext(null);
|
|
270
|
+
/**
|
|
271
|
+
* This is a provider for the CurrentUserContext.
|
|
272
|
+
*/
|
|
228
273
|
const CurrentUserProvider = (props) => {
|
|
229
274
|
return jsxRuntime.jsx(CurrentUserContext.Provider, Object.assign({}, props));
|
|
230
275
|
};
|
|
276
|
+
/**
|
|
277
|
+
* This is a hook to use the CurrentUserContext.
|
|
278
|
+
*/
|
|
231
279
|
const useCurrentUser = () => {
|
|
232
280
|
const context = React__namespace.useContext(CurrentUserContext);
|
|
233
281
|
if (!context) {
|
package/index.js
CHANGED
|
@@ -5,7 +5,13 @@ import { NavigationRuntime, AssetRuntime, CustomFieldRuntime, RestRuntime, SiteR
|
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
const AssetSortingContext = createContext(null);
|
|
8
|
+
/**
|
|
9
|
+
* This is a provider for the AssetSortingContext.
|
|
10
|
+
*/
|
|
8
11
|
const AssetSortingProvider = (props) => jsx(AssetSortingContext.Provider, Object.assign({}, props));
|
|
12
|
+
/**
|
|
13
|
+
* This is a hook to use the AssetSortingContext.
|
|
14
|
+
*/
|
|
9
15
|
const useAssetSorting = () => {
|
|
10
16
|
const context = useContext(AssetSortingContext);
|
|
11
17
|
if (!context) {
|
|
@@ -17,6 +23,9 @@ const useAssetSorting = () => {
|
|
|
17
23
|
const DeveloperSettingsContext = React.createContext({
|
|
18
24
|
localFeatureFlagsEnabled: false,
|
|
19
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* This is a hook to use the DeveloperSettingsContext.
|
|
28
|
+
*/
|
|
20
29
|
const useDeveloperSettings = () => {
|
|
21
30
|
const context = React.useContext(DeveloperSettingsContext);
|
|
22
31
|
if (!context) {
|
|
@@ -24,6 +33,9 @@ const useDeveloperSettings = () => {
|
|
|
24
33
|
}
|
|
25
34
|
return context;
|
|
26
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* This is the provider for Developer Settings
|
|
38
|
+
*/
|
|
27
39
|
const DeveloperSettingsProvider = ({ value, children }) => {
|
|
28
40
|
const [localFeatureFlagsEnabled, setLocalFeatureFlagsEnabled] = React.useState(false);
|
|
29
41
|
const [localFeatureFlags, setLocalFeatureFlags] = React.useState();
|
|
@@ -41,9 +53,15 @@ const DeveloperSettingsProvider = ({ value, children }) => {
|
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
const EnvironmentContext = createContext(null);
|
|
56
|
+
/**
|
|
57
|
+
* This is a provider for the EnvironmentContext.
|
|
58
|
+
*/
|
|
44
59
|
const EnvironmentContextProvider = (props) => {
|
|
45
60
|
return jsx(EnvironmentContext.Provider, Object.assign({}, props));
|
|
46
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* This is a hook to use the EnvironmentContext.
|
|
64
|
+
*/
|
|
47
65
|
const useEnvironment = () => {
|
|
48
66
|
const context = useContext(EnvironmentContext);
|
|
49
67
|
if (!context) {
|
|
@@ -53,6 +71,9 @@ const useEnvironment = () => {
|
|
|
53
71
|
};
|
|
54
72
|
|
|
55
73
|
const GlobalSelectionContext = React.createContext(null);
|
|
74
|
+
/**
|
|
75
|
+
* This is a hook to use the GlobalSelectionContext.
|
|
76
|
+
*/
|
|
56
77
|
const useGlobalSelection = () => {
|
|
57
78
|
const context = React.useContext(GlobalSelectionContext);
|
|
58
79
|
if (!context) {
|
|
@@ -60,6 +81,9 @@ const useGlobalSelection = () => {
|
|
|
60
81
|
}
|
|
61
82
|
return context;
|
|
62
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* This is a provider for the GlobalSelectionContext.
|
|
86
|
+
*/
|
|
63
87
|
const GlobalSelectionProvider = (props) => jsx(GlobalSelectionContext.Provider, Object.assign({}, props));
|
|
64
88
|
|
|
65
89
|
/**
|
|
@@ -165,9 +189,15 @@ const useSiteRuntime = () => {
|
|
|
165
189
|
};
|
|
166
190
|
|
|
167
191
|
const UserSubscriptionContext = React.createContext(null);
|
|
192
|
+
/**
|
|
193
|
+
* This is a provider for the UserSubscriptionContext.
|
|
194
|
+
*/
|
|
168
195
|
const UserSubscriptionProvider = (props) => {
|
|
169
196
|
return jsx(UserSubscriptionContext.Provider, Object.assign({}, props));
|
|
170
197
|
};
|
|
198
|
+
/**
|
|
199
|
+
* This is a hook to use the UserSubscriptionContext.
|
|
200
|
+
*/
|
|
171
201
|
const useUserSubscription = () => {
|
|
172
202
|
const context = React.useContext(UserSubscriptionContext);
|
|
173
203
|
if (!context) {
|
|
@@ -177,7 +207,13 @@ const useUserSubscription = () => {
|
|
|
177
207
|
};
|
|
178
208
|
|
|
179
209
|
const ToastContext = React.createContext(null);
|
|
210
|
+
/**
|
|
211
|
+
* This is a provider for the ToastContext.
|
|
212
|
+
*/
|
|
180
213
|
const ToastProvider = (props) => jsx(ToastContext.Provider, Object.assign({}, props));
|
|
214
|
+
/**
|
|
215
|
+
* This is a hook to use the ToastContext.
|
|
216
|
+
*/
|
|
181
217
|
const useToast = () => {
|
|
182
218
|
const toastContext = React.useContext(ToastContext);
|
|
183
219
|
if (!toastContext) {
|
|
@@ -187,6 +223,9 @@ const useToast = () => {
|
|
|
187
223
|
};
|
|
188
224
|
|
|
189
225
|
const TokenContext = React.createContext(null);
|
|
226
|
+
/**
|
|
227
|
+
* This is a hook to use the TokenContext.
|
|
228
|
+
*/
|
|
190
229
|
const useToken = () => {
|
|
191
230
|
const context = React.useContext(TokenContext);
|
|
192
231
|
if (!context) {
|
|
@@ -194,14 +233,23 @@ const useToken = () => {
|
|
|
194
233
|
}
|
|
195
234
|
return context;
|
|
196
235
|
};
|
|
236
|
+
/**
|
|
237
|
+
* This is a provider for the TokenContext.
|
|
238
|
+
*/
|
|
197
239
|
const TokenProvider = (props) => {
|
|
198
240
|
return jsx(TokenContext.Provider, Object.assign({}, props));
|
|
199
241
|
};
|
|
200
242
|
|
|
201
243
|
const CurrentUserContext = React.createContext(null);
|
|
244
|
+
/**
|
|
245
|
+
* This is a provider for the CurrentUserContext.
|
|
246
|
+
*/
|
|
202
247
|
const CurrentUserProvider = (props) => {
|
|
203
248
|
return jsx(CurrentUserContext.Provider, Object.assign({}, props));
|
|
204
249
|
};
|
|
250
|
+
/**
|
|
251
|
+
* This is a hook to use the CurrentUserContext.
|
|
252
|
+
*/
|
|
205
253
|
const useCurrentUser = () => {
|
|
206
254
|
const context = React.useContext(CurrentUserContext);
|
|
207
255
|
if (!context) {
|
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.38",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
11
|
+
"@trackunit/react-core-contexts-api": "0.2.23",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@trackunit/iris-app-runtime-core": "0.3.
|
|
14
|
-
"react-router-dom": "6.4.5"
|
|
13
|
+
"@trackunit/iris-app-runtime-core": "0.3.26",
|
|
14
|
+
"react-router-dom": "6.4.5",
|
|
15
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.24"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {}
|
|
17
18
|
}
|
|
@@ -4,6 +4,12 @@ interface Props {
|
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
value: IAssetSortingContext;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a provider for the AssetSortingContext.
|
|
9
|
+
*/
|
|
7
10
|
export declare const AssetSortingProvider: (props: Props) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* This is a hook to use the AssetSortingContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const useAssetSorting: () => IAssetSortingContext;
|
|
9
15
|
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { IDeveloperSettingsContext } from "@trackunit/react-core-contexts-api";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
export declare const DeveloperSettingsContext: React.Context<IDeveloperSettingsContext>;
|
|
4
|
+
/**
|
|
5
|
+
* This is a hook to use the DeveloperSettingsContext.
|
|
6
|
+
*/
|
|
4
7
|
export declare const useDeveloperSettings: () => IDeveloperSettingsContext;
|
|
5
8
|
interface IProps {
|
|
6
9
|
value: IDeveloperSettingsContext;
|
|
7
10
|
children: React.ReactNode;
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* This is the provider for Developer Settings
|
|
14
|
+
*/
|
|
9
15
|
export declare const DeveloperSettingsProvider: ({ value, children }: IProps) => JSX.Element;
|
|
10
16
|
export {};
|
|
@@ -4,6 +4,12 @@ interface IProps {
|
|
|
4
4
|
value: IEnvironmentContext;
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a provider for the EnvironmentContext.
|
|
9
|
+
*/
|
|
7
10
|
export declare const EnvironmentContextProvider: (props: IProps) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* This is a hook to use the EnvironmentContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const useEnvironment: () => IEnvironmentContext;
|
|
9
15
|
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { IGlobalSelectionContext } from "@trackunit/react-core-contexts-api";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* This is a hook to use the GlobalSelectionContext.
|
|
5
|
+
*/
|
|
3
6
|
export declare const useGlobalSelection: () => IGlobalSelectionContext;
|
|
4
7
|
interface IProps {
|
|
5
8
|
value: IGlobalSelectionContext;
|
|
6
9
|
children?: React.ReactNode;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* This is a provider for the GlobalSelectionContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const GlobalSelectionProvider: (props: IProps) => JSX.Element;
|
|
9
15
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ValueAndDefinition } from "@trackunit/iris-app-runtime-core";
|
|
2
|
+
import { EntityIdentity, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
/**
|
|
4
|
+
* Hook for getting and setting custom fields for an entity
|
|
5
|
+
*
|
|
6
|
+
* @param entity the entity to use
|
|
7
|
+
* @returns the hook for custom fields for the entity
|
|
8
|
+
*/
|
|
9
|
+
export declare const useCustomFieldRuntimeForEntity: (entity: EntityIdentity) => {
|
|
10
|
+
customFields: ValueAndDefinition[] | undefined;
|
|
11
|
+
setCustomFieldsFromFormDataForEntity: (formData: Record<string, boolean | string | string[] | number>) => Promise<void>;
|
|
12
|
+
setCustomFieldsForEntity: (values: ValueAndDefinitionKey[]) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -4,6 +4,12 @@ interface IProps {
|
|
|
4
4
|
value: IUserSubscriptionContext;
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a provider for the UserSubscriptionContext.
|
|
9
|
+
*/
|
|
7
10
|
export declare const UserSubscriptionProvider: (props: IProps) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* This is a hook to use the UserSubscriptionContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const useUserSubscription: () => IUserSubscriptionContext;
|
|
9
15
|
export {};
|
|
@@ -4,5 +4,11 @@ export interface ContextProviderProps {
|
|
|
4
4
|
value: IToastContext;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a provider for the ToastContext.
|
|
9
|
+
*/
|
|
7
10
|
export declare const ToastProvider: (props: ContextProviderProps) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* This is a hook to use the ToastContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const useToast: () => IToastContext;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ITokenContext } from "@trackunit/react-core-contexts-api";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* This is a hook to use the TokenContext.
|
|
5
|
+
*/
|
|
3
6
|
export declare const useToken: () => ITokenContext;
|
|
4
7
|
interface IProps {
|
|
5
8
|
value: ITokenContext;
|
|
6
9
|
children?: React.ReactNode;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* This is a provider for the TokenContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const TokenProvider: (props: IProps) => JSX.Element;
|
|
9
15
|
export {};
|
|
@@ -4,6 +4,12 @@ interface Props {
|
|
|
4
4
|
value: ICurrentUserContext;
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a provider for the CurrentUserContext.
|
|
9
|
+
*/
|
|
7
10
|
export declare const CurrentUserProvider: (props: Props) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* This is a hook to use the CurrentUserContext.
|
|
13
|
+
*/
|
|
8
14
|
export declare const useCurrentUser: () => ICurrentUserContext;
|
|
9
15
|
export {};
|