@trackunit/react-core-contexts-api 0.2.58 → 0.2.60
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 +46 -24
- package/index.esm.js +45 -25
- package/package.json +6 -2
- package/src/IUserPreferencesContext.d.ts +19 -0
- package/src/assetSortingContext.d.ts +7 -2
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var sharedUtils = require('@trackunit/shared-utils');
|
6
|
+
|
7
|
+
const SystemOfMeasurement = {
|
8
|
+
Si: "SI",
|
9
|
+
UsCustomary: "US_CUSTOMARY",
|
10
|
+
};
|
11
|
+
const TimeZonePreference = {
|
12
|
+
CustomTimeZone: "CUSTOM_TIME_ZONE",
|
13
|
+
LocalTimeZone: "LOCAL_TIME_ZONE",
|
14
|
+
MachineTimeZone: "MACHINE_TIME_ZONE",
|
15
|
+
};
|
16
|
+
|
5
17
|
/**
|
6
18
|
* Takes an event type and a description and returns an event
|
7
19
|
*
|
@@ -39,6 +51,28 @@ exports.AssetSortByProperty = void 0;
|
|
39
51
|
AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
|
40
52
|
AssetSortByProperty["Type"] = "TYPE";
|
41
53
|
})(exports.AssetSortByProperty || (exports.AssetSortByProperty = {}));
|
54
|
+
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
55
|
+
const stringToEnum = {
|
56
|
+
ACTIVITY: exports.AssetSortByProperty.Activity,
|
57
|
+
BRAND: exports.AssetSortByProperty.Brand,
|
58
|
+
CATEGORY: exports.AssetSortByProperty.Category,
|
59
|
+
CUSTOM_FIELD: exports.AssetSortByProperty.CustomField,
|
60
|
+
CRITICALITY: exports.AssetSortByProperty.Criticality,
|
61
|
+
ACCESS_MANAGEMENT: exports.AssetSortByProperty.AccessManagement,
|
62
|
+
EXTERNAL_REFERENCE: exports.AssetSortByProperty.ExternalReference,
|
63
|
+
LOCATION: exports.AssetSortByProperty.Location,
|
64
|
+
LOCATION_UPDATED_AT: exports.AssetSortByProperty.LocationUpdatedAt,
|
65
|
+
MODEL: exports.AssetSortByProperty.Model,
|
66
|
+
NAME: exports.AssetSortByProperty.Name,
|
67
|
+
OWNER_ACCOUNT_NAME: exports.AssetSortByProperty.OwnerAccountName,
|
68
|
+
PRODUCTION_YEAR: exports.AssetSortByProperty.ProductionYear,
|
69
|
+
SERIAL_NUMBER: exports.AssetSortByProperty.SerialNumber,
|
70
|
+
SERVICE_PLAN_ASSIGNMENT_STATUS: exports.AssetSortByProperty.ServicePlanAssignmentStatus,
|
71
|
+
SERVICE_PLAN_OVERDUENESS: exports.AssetSortByProperty.ServicePlanOverdueness,
|
72
|
+
SERVICE_PLAN_STATUS: exports.AssetSortByProperty.ServicePlanStatus,
|
73
|
+
TELEMATICS_DEVICE_SERIAL_NUMBER: exports.AssetSortByProperty.TelematicsDeviceSerialNumber,
|
74
|
+
TYPE: exports.AssetSortByProperty.Type,
|
75
|
+
};
|
42
76
|
/**
|
43
77
|
* Ensures that a string is a valid AssetSortByProperty enum value
|
44
78
|
*
|
@@ -48,33 +82,19 @@ exports.AssetSortByProperty = void 0;
|
|
48
82
|
const validateStringAsAssetSortByProperty = (input) => {
|
49
83
|
var _a;
|
50
84
|
const fallback = exports.AssetSortByProperty.Activity;
|
51
|
-
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
52
|
-
const stringToEnum = {
|
53
|
-
ACTIVITY: exports.AssetSortByProperty.Activity,
|
54
|
-
BRAND: exports.AssetSortByProperty.Brand,
|
55
|
-
CATEGORY: exports.AssetSortByProperty.Category,
|
56
|
-
CUSTOM_FIELD: exports.AssetSortByProperty.CustomField,
|
57
|
-
CRITICALITY: exports.AssetSortByProperty.Criticality,
|
58
|
-
ACCESS_MANAGEMENT: exports.AssetSortByProperty.AccessManagement,
|
59
|
-
EXTERNAL_REFERENCE: exports.AssetSortByProperty.ExternalReference,
|
60
|
-
LOCATION: exports.AssetSortByProperty.Location,
|
61
|
-
LOCATION_UPDATED_AT: exports.AssetSortByProperty.LocationUpdatedAt,
|
62
|
-
MODEL: exports.AssetSortByProperty.Model,
|
63
|
-
NAME: exports.AssetSortByProperty.Name,
|
64
|
-
OWNER_ACCOUNT_NAME: exports.AssetSortByProperty.OwnerAccountName,
|
65
|
-
PRODUCTION_YEAR: exports.AssetSortByProperty.ProductionYear,
|
66
|
-
SERIAL_NUMBER: exports.AssetSortByProperty.SerialNumber,
|
67
|
-
SERVICE_PLAN_ASSIGNMENT_STATUS: exports.AssetSortByProperty.ServicePlanAssignmentStatus,
|
68
|
-
SERVICE_PLAN_OVERDUENESS: exports.AssetSortByProperty.ServicePlanOverdueness,
|
69
|
-
SERVICE_PLAN_STATUS: exports.AssetSortByProperty.ServicePlanStatus,
|
70
|
-
TELEMATICS_DEVICE_SERIAL_NUMBER: exports.AssetSortByProperty.TelematicsDeviceSerialNumber,
|
71
|
-
TYPE: exports.AssetSortByProperty.Type,
|
72
|
-
};
|
73
85
|
if (!input) {
|
74
|
-
return fallback;
|
86
|
+
return { sortBy: fallback };
|
75
87
|
}
|
76
88
|
// Try to get the enum value from the string. -> Fallback to the default
|
77
|
-
|
89
|
+
if (sharedUtils.isUUID(input)) {
|
90
|
+
return {
|
91
|
+
sortBy: exports.AssetSortByProperty.CustomField,
|
92
|
+
customFieldDefinitionId: input,
|
93
|
+
};
|
94
|
+
}
|
95
|
+
return {
|
96
|
+
sortBy: (_a = stringToEnum[input]) !== null && _a !== void 0 ? _a : fallback,
|
97
|
+
};
|
78
98
|
};
|
79
99
|
exports.SortOrder = void 0;
|
80
100
|
(function (SortOrder) {
|
@@ -95,6 +115,8 @@ const UserSubscriptionPackage = {
|
|
95
115
|
NONE: "NONE",
|
96
116
|
};
|
97
117
|
|
118
|
+
exports.SystemOfMeasurement = SystemOfMeasurement;
|
119
|
+
exports.TimeZonePreference = TimeZonePreference;
|
98
120
|
exports.UserSubscriptionPackage = UserSubscriptionPackage;
|
99
121
|
exports.createEvent = createEvent;
|
100
122
|
exports.validateStringAsAssetSortByProperty = validateStringAsAssetSortByProperty;
|
package/index.esm.js
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
import { isUUID } from '@trackunit/shared-utils';
|
2
|
+
|
3
|
+
const SystemOfMeasurement = {
|
4
|
+
Si: "SI",
|
5
|
+
UsCustomary: "US_CUSTOMARY",
|
6
|
+
};
|
7
|
+
const TimeZonePreference = {
|
8
|
+
CustomTimeZone: "CUSTOM_TIME_ZONE",
|
9
|
+
LocalTimeZone: "LOCAL_TIME_ZONE",
|
10
|
+
MachineTimeZone: "MACHINE_TIME_ZONE",
|
11
|
+
};
|
12
|
+
|
1
13
|
/**
|
2
14
|
* Takes an event type and a description and returns an event
|
3
15
|
*
|
@@ -35,6 +47,28 @@ var AssetSortByProperty;
|
|
35
47
|
AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
|
36
48
|
AssetSortByProperty["Type"] = "TYPE";
|
37
49
|
})(AssetSortByProperty || (AssetSortByProperty = {}));
|
50
|
+
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
51
|
+
const stringToEnum = {
|
52
|
+
ACTIVITY: AssetSortByProperty.Activity,
|
53
|
+
BRAND: AssetSortByProperty.Brand,
|
54
|
+
CATEGORY: AssetSortByProperty.Category,
|
55
|
+
CUSTOM_FIELD: AssetSortByProperty.CustomField,
|
56
|
+
CRITICALITY: AssetSortByProperty.Criticality,
|
57
|
+
ACCESS_MANAGEMENT: AssetSortByProperty.AccessManagement,
|
58
|
+
EXTERNAL_REFERENCE: AssetSortByProperty.ExternalReference,
|
59
|
+
LOCATION: AssetSortByProperty.Location,
|
60
|
+
LOCATION_UPDATED_AT: AssetSortByProperty.LocationUpdatedAt,
|
61
|
+
MODEL: AssetSortByProperty.Model,
|
62
|
+
NAME: AssetSortByProperty.Name,
|
63
|
+
OWNER_ACCOUNT_NAME: AssetSortByProperty.OwnerAccountName,
|
64
|
+
PRODUCTION_YEAR: AssetSortByProperty.ProductionYear,
|
65
|
+
SERIAL_NUMBER: AssetSortByProperty.SerialNumber,
|
66
|
+
SERVICE_PLAN_ASSIGNMENT_STATUS: AssetSortByProperty.ServicePlanAssignmentStatus,
|
67
|
+
SERVICE_PLAN_OVERDUENESS: AssetSortByProperty.ServicePlanOverdueness,
|
68
|
+
SERVICE_PLAN_STATUS: AssetSortByProperty.ServicePlanStatus,
|
69
|
+
TELEMATICS_DEVICE_SERIAL_NUMBER: AssetSortByProperty.TelematicsDeviceSerialNumber,
|
70
|
+
TYPE: AssetSortByProperty.Type,
|
71
|
+
};
|
38
72
|
/**
|
39
73
|
* Ensures that a string is a valid AssetSortByProperty enum value
|
40
74
|
*
|
@@ -44,33 +78,19 @@ var AssetSortByProperty;
|
|
44
78
|
const validateStringAsAssetSortByProperty = (input) => {
|
45
79
|
var _a;
|
46
80
|
const fallback = AssetSortByProperty.Activity;
|
47
|
-
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
48
|
-
const stringToEnum = {
|
49
|
-
ACTIVITY: AssetSortByProperty.Activity,
|
50
|
-
BRAND: AssetSortByProperty.Brand,
|
51
|
-
CATEGORY: AssetSortByProperty.Category,
|
52
|
-
CUSTOM_FIELD: AssetSortByProperty.CustomField,
|
53
|
-
CRITICALITY: AssetSortByProperty.Criticality,
|
54
|
-
ACCESS_MANAGEMENT: AssetSortByProperty.AccessManagement,
|
55
|
-
EXTERNAL_REFERENCE: AssetSortByProperty.ExternalReference,
|
56
|
-
LOCATION: AssetSortByProperty.Location,
|
57
|
-
LOCATION_UPDATED_AT: AssetSortByProperty.LocationUpdatedAt,
|
58
|
-
MODEL: AssetSortByProperty.Model,
|
59
|
-
NAME: AssetSortByProperty.Name,
|
60
|
-
OWNER_ACCOUNT_NAME: AssetSortByProperty.OwnerAccountName,
|
61
|
-
PRODUCTION_YEAR: AssetSortByProperty.ProductionYear,
|
62
|
-
SERIAL_NUMBER: AssetSortByProperty.SerialNumber,
|
63
|
-
SERVICE_PLAN_ASSIGNMENT_STATUS: AssetSortByProperty.ServicePlanAssignmentStatus,
|
64
|
-
SERVICE_PLAN_OVERDUENESS: AssetSortByProperty.ServicePlanOverdueness,
|
65
|
-
SERVICE_PLAN_STATUS: AssetSortByProperty.ServicePlanStatus,
|
66
|
-
TELEMATICS_DEVICE_SERIAL_NUMBER: AssetSortByProperty.TelematicsDeviceSerialNumber,
|
67
|
-
TYPE: AssetSortByProperty.Type,
|
68
|
-
};
|
69
81
|
if (!input) {
|
70
|
-
return fallback;
|
82
|
+
return { sortBy: fallback };
|
71
83
|
}
|
72
84
|
// Try to get the enum value from the string. -> Fallback to the default
|
73
|
-
|
85
|
+
if (isUUID(input)) {
|
86
|
+
return {
|
87
|
+
sortBy: AssetSortByProperty.CustomField,
|
88
|
+
customFieldDefinitionId: input,
|
89
|
+
};
|
90
|
+
}
|
91
|
+
return {
|
92
|
+
sortBy: (_a = stringToEnum[input]) !== null && _a !== void 0 ? _a : fallback,
|
93
|
+
};
|
74
94
|
};
|
75
95
|
var SortOrder;
|
76
96
|
(function (SortOrder) {
|
@@ -91,4 +111,4 @@ const UserSubscriptionPackage = {
|
|
91
111
|
NONE: "NONE",
|
92
112
|
};
|
93
113
|
|
94
|
-
export { AssetSortByProperty, SortOrder, UserSubscriptionPackage, createEvent, validateStringAsAssetSortByProperty };
|
114
|
+
export { AssetSortByProperty, SortOrder, SystemOfMeasurement, TimeZonePreference, UserSubscriptionPackage, createEvent, validateStringAsAssetSortByProperty };
|
package/package.json
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "@trackunit/react-core-contexts-api",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.60",
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"engines": {
|
7
7
|
"node": ">=18.x"
|
8
8
|
},
|
9
9
|
"module": "./index.esm.js",
|
10
|
-
"main": "./index.cjs.js"
|
10
|
+
"main": "./index.cjs.js",
|
11
|
+
"dependencies": {
|
12
|
+
"@trackunit/shared-utils": "0.0.9"
|
13
|
+
},
|
14
|
+
"peerDependencies": {}
|
11
15
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export declare const SystemOfMeasurement: {
|
2
|
+
readonly Si: "SI";
|
3
|
+
readonly UsCustomary: "US_CUSTOMARY";
|
4
|
+
};
|
5
|
+
export declare const TimeZonePreference: {
|
6
|
+
readonly CustomTimeZone: "CUSTOM_TIME_ZONE";
|
7
|
+
readonly LocalTimeZone: "LOCAL_TIME_ZONE";
|
8
|
+
readonly MachineTimeZone: "MACHINE_TIME_ZONE";
|
9
|
+
};
|
10
|
+
export type SystemOfMeasurementType = (typeof SystemOfMeasurement)[keyof typeof SystemOfMeasurement];
|
11
|
+
export type TimeZonePreferenceType = (typeof TimeZonePreference)[keyof typeof TimeZonePreference];
|
12
|
+
export interface IUserPreferencesContext {
|
13
|
+
language?: string;
|
14
|
+
setLanguage?: (language: string) => void;
|
15
|
+
timeZonePreference?: TimeZonePreferenceType;
|
16
|
+
setTimeZonePreference?: (timeZonePreference: TimeZonePreferenceType) => void;
|
17
|
+
systemOfMeasurement?: SystemOfMeasurementType;
|
18
|
+
setSystemOfMeasurement?: (systemOfMeasurement: SystemOfMeasurementType) => void;
|
19
|
+
}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
export interface IAssetSortingContext {
|
2
2
|
sortingState: SortingState;
|
3
|
-
setSortBy: (sortBy: AssetSortByProperty, order?: SortOrder) => void;
|
3
|
+
setSortBy: (sortBy: AssetSortByProperty, order?: SortOrder, customFieldDefinitionId?: string) => void;
|
4
4
|
}
|
5
5
|
export interface SortingState {
|
6
|
+
/** Custom field definitionId if AssetSortByProperty is a CustomField */
|
7
|
+
customFieldDefinitionId?: string;
|
6
8
|
/** The property to sort by. */
|
7
9
|
sortBy: AssetSortByProperty;
|
8
10
|
/** The property to sort by. */
|
@@ -35,7 +37,10 @@ export declare enum AssetSortByProperty {
|
|
35
37
|
* @param input A string to test against AssetSortByProperty
|
36
38
|
* @returns {AssetSortByProperty.Activity} The AssetSortByProperty enum value or the default value (AssetSortByProperty.Activity)
|
37
39
|
*/
|
38
|
-
export declare const validateStringAsAssetSortByProperty: (input?: string) =>
|
40
|
+
export declare const validateStringAsAssetSortByProperty: (input?: string) => {
|
41
|
+
sortBy: AssetSortByProperty;
|
42
|
+
customFieldDefinitionId?: string;
|
43
|
+
};
|
39
44
|
export declare enum SortOrder {
|
40
45
|
Asc = "ASC",
|
41
46
|
Desc = "DESC"
|
package/src/index.d.ts
CHANGED