@trackunit/iris-app-runtime-core 0.3.146 → 0.3.147
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 +33 -39
- package/index.esm.js +32 -39
- package/package.json +1 -1
- package/src/CustomFieldRuntime.d.ts +9 -8
package/index.cjs.js
CHANGED
|
@@ -253,44 +253,37 @@ const getDateValue = (value) => {
|
|
|
253
253
|
const year = date.toLocaleString("en-US", { year: "numeric" });
|
|
254
254
|
return `${year}-${month}-${day}`;
|
|
255
255
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
const numberValue = Number(value);
|
|
289
|
-
const numberAsString = numberValue > 9999
|
|
290
|
-
? Math.round(numberValue)
|
|
291
|
-
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
292
|
-
return numberAsString;
|
|
293
|
-
},
|
|
256
|
+
/**
|
|
257
|
+
* Format a custom field value to ensure a consistent representation in the ui.
|
|
258
|
+
*/
|
|
259
|
+
const getCustomFieldValueForDisplayInUI = (value, _unit, _systemOfMeasurement, language) => {
|
|
260
|
+
if (value === undefined || value === null || value === "") {
|
|
261
|
+
return "";
|
|
262
|
+
}
|
|
263
|
+
const numberValue = Number(value);
|
|
264
|
+
const numberAsString = numberValue > 9999
|
|
265
|
+
? Math.round(numberValue)
|
|
266
|
+
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
267
|
+
return numberAsString;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* type guard to ensure that a value is of a type compatible with custom fields
|
|
271
|
+
*/
|
|
272
|
+
const isValidCustomFieldValue = (value) => {
|
|
273
|
+
const isBoolean = typeof value === "boolean";
|
|
274
|
+
const isString = typeof value === "string";
|
|
275
|
+
const isStringArray = Array.isArray(value) && value.every(item => typeof item === "string");
|
|
276
|
+
const isDropdownSelectionArray = Array.isArray(value) && value.every(item => isDropdownSelection(item));
|
|
277
|
+
const isDropdownSelection = (dropdownValue) => typeof dropdownValue === "object" && dropdownValue !== null && "value" in dropdownValue;
|
|
278
|
+
const isNumber = typeof value === "number";
|
|
279
|
+
const isNull = value === null;
|
|
280
|
+
return (isBoolean ||
|
|
281
|
+
isString ||
|
|
282
|
+
isStringArray ||
|
|
283
|
+
isDropdownSelectionArray ||
|
|
284
|
+
isDropdownSelection(value) ||
|
|
285
|
+
isNumber ||
|
|
286
|
+
isNull);
|
|
294
287
|
};
|
|
295
288
|
|
|
296
289
|
const EnvironmentRuntime = {
|
|
@@ -429,7 +422,6 @@ exports.AssetSortingRuntime = AssetSortingRuntime;
|
|
|
429
422
|
exports.ConfirmationDialogRuntime = ConfirmationDialogRuntime;
|
|
430
423
|
exports.CurrentUserPreferenceRuntime = CurrentUserPreferenceRuntime;
|
|
431
424
|
exports.CurrentUserRuntime = CurrentUserRuntime;
|
|
432
|
-
exports.CustomFieldRuntime = CustomFieldRuntime;
|
|
433
425
|
exports.EnvironmentRuntime = EnvironmentRuntime;
|
|
434
426
|
exports.EventRuntime = EventRuntime;
|
|
435
427
|
exports.FilterBarRuntime = FilterBarRuntime;
|
|
@@ -442,10 +434,12 @@ exports.SiteRuntime = SiteRuntime;
|
|
|
442
434
|
exports.ToastRuntime = ToastRuntime;
|
|
443
435
|
exports.TokenRuntime = TokenRuntime;
|
|
444
436
|
exports.UserSubscriptionRuntime = UserSubscriptionRuntime;
|
|
437
|
+
exports.getCustomFieldValueForDisplayInUI = getCustomFieldValueForDisplayInUI;
|
|
445
438
|
exports.getCustomFieldValueToSaveFromRawValue = getCustomFieldValueToSaveFromRawValue;
|
|
446
439
|
exports.getDateValue = getDateValue;
|
|
447
440
|
exports.getHostConnector = getHostConnector;
|
|
448
441
|
exports.getStringValue = getStringValue;
|
|
442
|
+
exports.isValidCustomFieldValue = isValidCustomFieldValue;
|
|
449
443
|
exports.setupHostConnector = setupHostConnector;
|
|
450
444
|
Object.keys(irisAppRuntimeCoreApi).forEach(function (k) {
|
|
451
445
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
package/index.esm.js
CHANGED
|
@@ -249,44 +249,37 @@ const getDateValue = (value) => {
|
|
|
249
249
|
const year = date.toLocaleString("en-US", { year: "numeric" });
|
|
250
250
|
return `${year}-${month}-${day}`;
|
|
251
251
|
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
const numberValue = Number(value);
|
|
285
|
-
const numberAsString = numberValue > 9999
|
|
286
|
-
? Math.round(numberValue)
|
|
287
|
-
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
288
|
-
return numberAsString;
|
|
289
|
-
},
|
|
252
|
+
/**
|
|
253
|
+
* Format a custom field value to ensure a consistent representation in the ui.
|
|
254
|
+
*/
|
|
255
|
+
const getCustomFieldValueForDisplayInUI = (value, _unit, _systemOfMeasurement, language) => {
|
|
256
|
+
if (value === undefined || value === null || value === "") {
|
|
257
|
+
return "";
|
|
258
|
+
}
|
|
259
|
+
const numberValue = Number(value);
|
|
260
|
+
const numberAsString = numberValue > 9999
|
|
261
|
+
? Math.round(numberValue)
|
|
262
|
+
: new Intl.NumberFormat(language, { maximumSignificantDigits: 4, minimumSignificantDigits: 4 }).format(numberValue);
|
|
263
|
+
return numberAsString;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* type guard to ensure that a value is of a type compatible with custom fields
|
|
267
|
+
*/
|
|
268
|
+
const isValidCustomFieldValue = (value) => {
|
|
269
|
+
const isBoolean = typeof value === "boolean";
|
|
270
|
+
const isString = typeof value === "string";
|
|
271
|
+
const isStringArray = Array.isArray(value) && value.every(item => typeof item === "string");
|
|
272
|
+
const isDropdownSelectionArray = Array.isArray(value) && value.every(item => isDropdownSelection(item));
|
|
273
|
+
const isDropdownSelection = (dropdownValue) => typeof dropdownValue === "object" && dropdownValue !== null && "value" in dropdownValue;
|
|
274
|
+
const isNumber = typeof value === "number";
|
|
275
|
+
const isNull = value === null;
|
|
276
|
+
return (isBoolean ||
|
|
277
|
+
isString ||
|
|
278
|
+
isStringArray ||
|
|
279
|
+
isDropdownSelectionArray ||
|
|
280
|
+
isDropdownSelection(value) ||
|
|
281
|
+
isNumber ||
|
|
282
|
+
isNull);
|
|
290
283
|
};
|
|
291
284
|
|
|
292
285
|
const EnvironmentRuntime = {
|
|
@@ -419,4 +412,4 @@ const UserSubscriptionRuntime = {
|
|
|
419
412
|
}),
|
|
420
413
|
};
|
|
421
414
|
|
|
422
|
-
export { AnalyticsContextRuntime, AssetRuntime, AssetSortingRuntime, ConfirmationDialogRuntime, CurrentUserPreferenceRuntime, CurrentUserRuntime,
|
|
415
|
+
export { AnalyticsContextRuntime, AssetRuntime, AssetSortingRuntime, ConfirmationDialogRuntime, CurrentUserPreferenceRuntime, CurrentUserRuntime, EnvironmentRuntime, EventRuntime, FilterBarRuntime, NavigationRuntime, OemBrandingContextRuntime, ParamsRuntime, RestRuntime, RouterRuntime, SiteRuntime, ToastRuntime, TokenRuntime, UserSubscriptionRuntime, getCustomFieldValueForDisplayInUI, getCustomFieldValueToSaveFromRawValue, getDateValue, getHostConnector, getStringValue, isValidCustomFieldValue, setupHostConnector };
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomFieldType, CustomFieldValue, UnitSiType, UnitUsType } from "@trackunit/iris-app-runtime-core-api";
|
|
2
2
|
import { SystemOfMeasurementType } from "@trackunit/react-core-contexts-api";
|
|
3
3
|
export interface DropdownSelection {
|
|
4
4
|
value: string;
|
|
@@ -23,10 +23,11 @@ export declare const getStringValue: (value: boolean | string | string[] | Dropd
|
|
|
23
23
|
* yyyy-mm-dd
|
|
24
24
|
*/
|
|
25
25
|
export declare const getDateValue: (value: string) => string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Format a custom field value to ensure a consistent representation in the ui.
|
|
28
|
+
*/
|
|
29
|
+
export declare const getCustomFieldValueForDisplayInUI: (value: number | string | null | undefined, _unit: UnitUsType | UnitSiType | null | undefined, _systemOfMeasurement?: SystemOfMeasurementType | null, language?: string) => number | string | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* type guard to ensure that a value is of a type compatible with custom fields
|
|
32
|
+
*/
|
|
33
|
+
export declare const isValidCustomFieldValue: (value: unknown) => value is string | number | boolean | DropdownSelection | string[] | DropdownSelection[] | null;
|