@trackunit/react-core-hooks 0.2.170 → 0.2.171
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.js
CHANGED
|
@@ -308,61 +308,6 @@ const useAssetRuntime = () => {
|
|
|
308
308
|
return { assetInfo, loading, error };
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
/**
|
|
312
|
-
* A hook to expose custom field runtime methods
|
|
313
|
-
*
|
|
314
|
-
* @returns {UseCustomFieldRuntime} CustomFieldRuntime
|
|
315
|
-
*/
|
|
316
|
-
const useCustomFieldRuntime = () => {
|
|
317
|
-
return irisAppRuntimeCore.CustomFieldRuntime;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* This hook is a wrapper around useCustomFieldRuntime that automatically fetches and sets custom fields for a given entity.
|
|
322
|
-
*
|
|
323
|
-
* @param entity The entity to fetch and set custom fields for.
|
|
324
|
-
* @returns The custom fields for the entity, and functions to set custom fields for the entity.
|
|
325
|
-
* @example
|
|
326
|
-
* import { useAssetRuntime, useCustomFieldRuntimeForEntity } from '@trackunit/react-core-hooks';
|
|
327
|
-
* const { assetInfo } = useAssetRuntime();
|
|
328
|
-
* const { customFields, setCustomFieldsForEntity } = useCustomFieldRuntimeForEntity( {
|
|
329
|
-
* id: assetInfo?.assetId || '',
|
|
330
|
-
* type: 'ASSET'
|
|
331
|
-
* });
|
|
332
|
-
*
|
|
333
|
-
* // set custom field data
|
|
334
|
-
* setCustomFieldsForEntity({"key": "value"});
|
|
335
|
-
*/
|
|
336
|
-
const useCustomFieldRuntimeForEntity = (entity) => {
|
|
337
|
-
const { getCustomFieldsFor, setCustomFieldsFromFormData, setCustomFieldsFor } = useCustomFieldRuntime();
|
|
338
|
-
const [customFields, setCustomFields] = React.useState();
|
|
339
|
-
React.useEffect(() => {
|
|
340
|
-
if (entity.id) {
|
|
341
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
342
|
-
setCustomFields(yield getCustomFieldsFor(entity));
|
|
343
|
-
}))();
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
setCustomFields([]);
|
|
347
|
-
}
|
|
348
|
-
}, [entity, getCustomFieldsFor]);
|
|
349
|
-
const setCustomFieldsForEntity = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
350
|
-
if (entity.id) {
|
|
351
|
-
yield setCustomFieldsFor(entity, values);
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
const setCustomFieldsFromFormDataForEntity = (formData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
355
|
-
if (entity.id) {
|
|
356
|
-
yield setCustomFieldsFromFormData(entity, formData, customFields || []);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
return {
|
|
360
|
-
customFields,
|
|
361
|
-
setCustomFieldsFromFormDataForEntity,
|
|
362
|
-
setCustomFieldsForEntity,
|
|
363
|
-
};
|
|
364
|
-
};
|
|
365
|
-
|
|
366
311
|
/**
|
|
367
312
|
* A hook to expose event runtime for React components
|
|
368
313
|
*
|
|
@@ -711,8 +656,6 @@ exports.useCurrentUser = useCurrentUser;
|
|
|
711
656
|
exports.useCurrentUserLanguage = useCurrentUserLanguage;
|
|
712
657
|
exports.useCurrentUserSystemOfMeasurement = useCurrentUserSystemOfMeasurement;
|
|
713
658
|
exports.useCurrentUserTimeZonePreference = useCurrentUserTimeZonePreference;
|
|
714
|
-
exports.useCustomFieldRuntime = useCustomFieldRuntime;
|
|
715
|
-
exports.useCustomFieldRuntimeForEntity = useCustomFieldRuntimeForEntity;
|
|
716
659
|
exports.useEnvironment = useEnvironment;
|
|
717
660
|
exports.useEventRuntime = useEventRuntime;
|
|
718
661
|
exports.useFilterBarContext = useFilterBarContext;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { AssetRuntime,
|
|
4
|
+
import { AssetRuntime, EventRuntime, ParamsRuntime, SiteRuntime } from '@trackunit/iris-app-runtime-core';
|
|
5
5
|
import { filterByMultiple } from '@trackunit/shared-utils';
|
|
6
6
|
|
|
7
7
|
const AnalyticsContext = createContext(null);
|
|
@@ -285,61 +285,6 @@ const useAssetRuntime = () => {
|
|
|
285
285
|
return { assetInfo, loading, error };
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
/**
|
|
289
|
-
* A hook to expose custom field runtime methods
|
|
290
|
-
*
|
|
291
|
-
* @returns {UseCustomFieldRuntime} CustomFieldRuntime
|
|
292
|
-
*/
|
|
293
|
-
const useCustomFieldRuntime = () => {
|
|
294
|
-
return CustomFieldRuntime;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* This hook is a wrapper around useCustomFieldRuntime that automatically fetches and sets custom fields for a given entity.
|
|
299
|
-
*
|
|
300
|
-
* @param entity The entity to fetch and set custom fields for.
|
|
301
|
-
* @returns The custom fields for the entity, and functions to set custom fields for the entity.
|
|
302
|
-
* @example
|
|
303
|
-
* import { useAssetRuntime, useCustomFieldRuntimeForEntity } from '@trackunit/react-core-hooks';
|
|
304
|
-
* const { assetInfo } = useAssetRuntime();
|
|
305
|
-
* const { customFields, setCustomFieldsForEntity } = useCustomFieldRuntimeForEntity( {
|
|
306
|
-
* id: assetInfo?.assetId || '',
|
|
307
|
-
* type: 'ASSET'
|
|
308
|
-
* });
|
|
309
|
-
*
|
|
310
|
-
* // set custom field data
|
|
311
|
-
* setCustomFieldsForEntity({"key": "value"});
|
|
312
|
-
*/
|
|
313
|
-
const useCustomFieldRuntimeForEntity = (entity) => {
|
|
314
|
-
const { getCustomFieldsFor, setCustomFieldsFromFormData, setCustomFieldsFor } = useCustomFieldRuntime();
|
|
315
|
-
const [customFields, setCustomFields] = useState();
|
|
316
|
-
useEffect(() => {
|
|
317
|
-
if (entity.id) {
|
|
318
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
319
|
-
setCustomFields(yield getCustomFieldsFor(entity));
|
|
320
|
-
}))();
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
setCustomFields([]);
|
|
324
|
-
}
|
|
325
|
-
}, [entity, getCustomFieldsFor]);
|
|
326
|
-
const setCustomFieldsForEntity = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
327
|
-
if (entity.id) {
|
|
328
|
-
yield setCustomFieldsFor(entity, values);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
const setCustomFieldsFromFormDataForEntity = (formData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
332
|
-
if (entity.id) {
|
|
333
|
-
yield setCustomFieldsFromFormData(entity, formData, customFields || []);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
return {
|
|
337
|
-
customFields,
|
|
338
|
-
setCustomFieldsFromFormDataForEntity,
|
|
339
|
-
setCustomFieldsForEntity,
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
|
|
343
288
|
/**
|
|
344
289
|
* A hook to expose event runtime for React components
|
|
345
290
|
*
|
|
@@ -667,4 +612,4 @@ const useCurrentUser = () => {
|
|
|
667
612
|
return context;
|
|
668
613
|
};
|
|
669
614
|
|
|
670
|
-
export { AnalyticsContext, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, CurrentUserPreferenceProvider, CurrentUserProvider, EnvironmentContextProvider, FilterBarProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeZonePreference,
|
|
615
|
+
export { AnalyticsContext, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, CurrentUserPreferenceProvider, CurrentUserProvider, EnvironmentContextProvider, FilterBarProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeZonePreference, useEnvironment, useEventRuntime, useFilterBarContext, useHasAccessTo, useIrisAppName, useNavigateInHost, useOemBrandingContext, useSiteRuntime, useTextSearch, useToast, useToken, 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.171",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"@trackunit/react-core-contexts-api": "*",
|
|
11
11
|
"react": "^18.2.0",
|
|
12
12
|
"@trackunit/iris-app-runtime-core": "*",
|
|
13
|
-
"@trackunit/iris-app-runtime-core-api": "*",
|
|
14
13
|
"jest-fetch-mock": "^3.0.3",
|
|
15
14
|
"@trackunit/shared-utils": "*"
|
|
16
15
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export * from "./filter-bar/FilterBarProvider";
|
|
|
6
6
|
export * from "./irisOemApp/IrisOemAppContextProvider";
|
|
7
7
|
export * from "./navigation/NavigationContextProvider";
|
|
8
8
|
export * from "./runtimes/useAssetRuntime";
|
|
9
|
-
export * from "./runtimes/useCustomFieldRuntime";
|
|
10
|
-
export * from "./runtimes/useCustomFieldRuntimeForEntity";
|
|
11
9
|
export * from "./runtimes/useEventRuntime";
|
|
12
10
|
export * from "./runtimes/useParamsRuntime";
|
|
13
11
|
export * from "./runtimes/useSiteRuntime";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ICustomFieldRuntime } from "@trackunit/iris-app-runtime-core";
|
|
2
|
-
export interface UseCustomFieldRuntime extends ICustomFieldRuntime {
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* A hook to expose custom field runtime methods
|
|
6
|
-
*
|
|
7
|
-
* @returns {UseCustomFieldRuntime} CustomFieldRuntime
|
|
8
|
-
*/
|
|
9
|
-
export declare const useCustomFieldRuntime: () => UseCustomFieldRuntime;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ValueAndDefinition } from "@trackunit/iris-app-runtime-core";
|
|
2
|
-
import { EntityIdentity, ValueAndDefinitionKey } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
-
/**
|
|
4
|
-
* This hook is a wrapper around useCustomFieldRuntime that automatically fetches and sets custom fields for a given entity.
|
|
5
|
-
*
|
|
6
|
-
* @param entity The entity to fetch and set custom fields for.
|
|
7
|
-
* @returns The custom fields for the entity, and functions to set custom fields for the entity.
|
|
8
|
-
* @example
|
|
9
|
-
* import { useAssetRuntime, useCustomFieldRuntimeForEntity } from '@trackunit/react-core-hooks';
|
|
10
|
-
* const { assetInfo } = useAssetRuntime();
|
|
11
|
-
* const { customFields, setCustomFieldsForEntity } = useCustomFieldRuntimeForEntity( {
|
|
12
|
-
* id: assetInfo?.assetId || '',
|
|
13
|
-
* type: 'ASSET'
|
|
14
|
-
* });
|
|
15
|
-
*
|
|
16
|
-
* // set custom field data
|
|
17
|
-
* setCustomFieldsForEntity({"key": "value"});
|
|
18
|
-
*/
|
|
19
|
-
export declare const useCustomFieldRuntimeForEntity: (entity: EntityIdentity) => {
|
|
20
|
-
customFields: ValueAndDefinition[] | undefined;
|
|
21
|
-
setCustomFieldsFromFormDataForEntity: (formData: Record<string, boolean | string | string[] | number>) => Promise<void>;
|
|
22
|
-
setCustomFieldsForEntity: (values: ValueAndDefinitionKey[]) => Promise<void>;
|
|
23
|
-
};
|