@trackunit/react-core-contexts-api 0.2.59 → 0.2.61
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 +34 -24
- package/index.esm.js +34 -24
- package/package.json +6 -2
- package/src/assetSortingContext.d.ts +7 -2
package/index.cjs.js
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var sharedUtils = require('@trackunit/shared-utils');
|
6
|
+
|
5
7
|
const SystemOfMeasurement = {
|
6
8
|
Si: "SI",
|
7
9
|
UsCustomary: "US_CUSTOMARY",
|
@@ -49,6 +51,28 @@ exports.AssetSortByProperty = void 0;
|
|
49
51
|
AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
|
50
52
|
AssetSortByProperty["Type"] = "TYPE";
|
51
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
|
+
};
|
52
76
|
/**
|
53
77
|
* Ensures that a string is a valid AssetSortByProperty enum value
|
54
78
|
*
|
@@ -58,33 +82,19 @@ exports.AssetSortByProperty = void 0;
|
|
58
82
|
const validateStringAsAssetSortByProperty = (input) => {
|
59
83
|
var _a;
|
60
84
|
const fallback = exports.AssetSortByProperty.Activity;
|
61
|
-
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
62
|
-
const stringToEnum = {
|
63
|
-
ACTIVITY: exports.AssetSortByProperty.Activity,
|
64
|
-
BRAND: exports.AssetSortByProperty.Brand,
|
65
|
-
CATEGORY: exports.AssetSortByProperty.Category,
|
66
|
-
CUSTOM_FIELD: exports.AssetSortByProperty.CustomField,
|
67
|
-
CRITICALITY: exports.AssetSortByProperty.Criticality,
|
68
|
-
ACCESS_MANAGEMENT: exports.AssetSortByProperty.AccessManagement,
|
69
|
-
EXTERNAL_REFERENCE: exports.AssetSortByProperty.ExternalReference,
|
70
|
-
LOCATION: exports.AssetSortByProperty.Location,
|
71
|
-
LOCATION_UPDATED_AT: exports.AssetSortByProperty.LocationUpdatedAt,
|
72
|
-
MODEL: exports.AssetSortByProperty.Model,
|
73
|
-
NAME: exports.AssetSortByProperty.Name,
|
74
|
-
OWNER_ACCOUNT_NAME: exports.AssetSortByProperty.OwnerAccountName,
|
75
|
-
PRODUCTION_YEAR: exports.AssetSortByProperty.ProductionYear,
|
76
|
-
SERIAL_NUMBER: exports.AssetSortByProperty.SerialNumber,
|
77
|
-
SERVICE_PLAN_ASSIGNMENT_STATUS: exports.AssetSortByProperty.ServicePlanAssignmentStatus,
|
78
|
-
SERVICE_PLAN_OVERDUENESS: exports.AssetSortByProperty.ServicePlanOverdueness,
|
79
|
-
SERVICE_PLAN_STATUS: exports.AssetSortByProperty.ServicePlanStatus,
|
80
|
-
TELEMATICS_DEVICE_SERIAL_NUMBER: exports.AssetSortByProperty.TelematicsDeviceSerialNumber,
|
81
|
-
TYPE: exports.AssetSortByProperty.Type,
|
82
|
-
};
|
83
85
|
if (!input) {
|
84
|
-
return fallback;
|
86
|
+
return { sortBy: fallback };
|
85
87
|
}
|
86
88
|
// Try to get the enum value from the string. -> Fallback to the default
|
87
|
-
|
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
|
+
};
|
88
98
|
};
|
89
99
|
exports.SortOrder = void 0;
|
90
100
|
(function (SortOrder) {
|
package/index.esm.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { isUUID } from '@trackunit/shared-utils';
|
2
|
+
|
1
3
|
const SystemOfMeasurement = {
|
2
4
|
Si: "SI",
|
3
5
|
UsCustomary: "US_CUSTOMARY",
|
@@ -45,6 +47,28 @@ var AssetSortByProperty;
|
|
45
47
|
AssetSortByProperty["TelematicsDeviceSerialNumber"] = "TELEMATICS_DEVICE_SERIAL_NUMBER";
|
46
48
|
AssetSortByProperty["Type"] = "TYPE";
|
47
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
|
+
};
|
48
72
|
/**
|
49
73
|
* Ensures that a string is a valid AssetSortByProperty enum value
|
50
74
|
*
|
@@ -54,33 +78,19 @@ var AssetSortByProperty;
|
|
54
78
|
const validateStringAsAssetSortByProperty = (input) => {
|
55
79
|
var _a;
|
56
80
|
const fallback = AssetSortByProperty.Activity;
|
57
|
-
// The type [key in AssetSortByProperty] will insure that ALL keys are present
|
58
|
-
const stringToEnum = {
|
59
|
-
ACTIVITY: AssetSortByProperty.Activity,
|
60
|
-
BRAND: AssetSortByProperty.Brand,
|
61
|
-
CATEGORY: AssetSortByProperty.Category,
|
62
|
-
CUSTOM_FIELD: AssetSortByProperty.CustomField,
|
63
|
-
CRITICALITY: AssetSortByProperty.Criticality,
|
64
|
-
ACCESS_MANAGEMENT: AssetSortByProperty.AccessManagement,
|
65
|
-
EXTERNAL_REFERENCE: AssetSortByProperty.ExternalReference,
|
66
|
-
LOCATION: AssetSortByProperty.Location,
|
67
|
-
LOCATION_UPDATED_AT: AssetSortByProperty.LocationUpdatedAt,
|
68
|
-
MODEL: AssetSortByProperty.Model,
|
69
|
-
NAME: AssetSortByProperty.Name,
|
70
|
-
OWNER_ACCOUNT_NAME: AssetSortByProperty.OwnerAccountName,
|
71
|
-
PRODUCTION_YEAR: AssetSortByProperty.ProductionYear,
|
72
|
-
SERIAL_NUMBER: AssetSortByProperty.SerialNumber,
|
73
|
-
SERVICE_PLAN_ASSIGNMENT_STATUS: AssetSortByProperty.ServicePlanAssignmentStatus,
|
74
|
-
SERVICE_PLAN_OVERDUENESS: AssetSortByProperty.ServicePlanOverdueness,
|
75
|
-
SERVICE_PLAN_STATUS: AssetSortByProperty.ServicePlanStatus,
|
76
|
-
TELEMATICS_DEVICE_SERIAL_NUMBER: AssetSortByProperty.TelematicsDeviceSerialNumber,
|
77
|
-
TYPE: AssetSortByProperty.Type,
|
78
|
-
};
|
79
81
|
if (!input) {
|
80
|
-
return fallback;
|
82
|
+
return { sortBy: fallback };
|
81
83
|
}
|
82
84
|
// Try to get the enum value from the string. -> Fallback to the default
|
83
|
-
|
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
|
+
};
|
84
94
|
};
|
85
95
|
var SortOrder;
|
86
96
|
(function (SortOrder) {
|
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.61",
|
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.10"
|
13
|
+
},
|
14
|
+
"peerDependencies": {}
|
11
15
|
}
|
@@ -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"
|