@trackunit/iris-app-runtime-core 0.3.145 → 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 +41 -43
- package/index.esm.js +39 -43
- package/package.json +1 -1
- package/src/CustomFieldRuntime.d.ts +9 -8
- package/src/NavigationRuntime.d.ts +1 -4
- package/src/RouterRuntime.d.ts +4 -0
- package/src/index.d.ts +1 -0
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 = {
|
|
@@ -326,10 +319,6 @@ const OemBrandingContextRuntime = {
|
|
|
326
319
|
};
|
|
327
320
|
|
|
328
321
|
const NavigationRuntime = {
|
|
329
|
-
setDeepLink: (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
330
|
-
const api = yield getHostConnector();
|
|
331
|
-
return api.setDeepLink(props);
|
|
332
|
-
}),
|
|
333
322
|
gotoAssetHome: (assetId, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
334
323
|
const api = yield getHostConnector();
|
|
335
324
|
return api.gotoAssetHome(assetId, options);
|
|
@@ -377,6 +366,13 @@ const RestRuntime = {
|
|
|
377
366
|
},
|
|
378
367
|
};
|
|
379
368
|
|
|
369
|
+
const RouterRuntime = {
|
|
370
|
+
getBasePath: () => {
|
|
371
|
+
var _a;
|
|
372
|
+
return `${((_a = document.getElementById("baseHref")) === null || _a === void 0 ? void 0 : _a.getAttribute("href")) || "<missing baseHref>"}${global.module}`;
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
|
|
380
376
|
const SiteRuntime = {
|
|
381
377
|
getSiteInfo: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
382
378
|
const api = yield getHostConnector();
|
|
@@ -426,7 +422,6 @@ exports.AssetSortingRuntime = AssetSortingRuntime;
|
|
|
426
422
|
exports.ConfirmationDialogRuntime = ConfirmationDialogRuntime;
|
|
427
423
|
exports.CurrentUserPreferenceRuntime = CurrentUserPreferenceRuntime;
|
|
428
424
|
exports.CurrentUserRuntime = CurrentUserRuntime;
|
|
429
|
-
exports.CustomFieldRuntime = CustomFieldRuntime;
|
|
430
425
|
exports.EnvironmentRuntime = EnvironmentRuntime;
|
|
431
426
|
exports.EventRuntime = EventRuntime;
|
|
432
427
|
exports.FilterBarRuntime = FilterBarRuntime;
|
|
@@ -434,14 +429,17 @@ exports.NavigationRuntime = NavigationRuntime;
|
|
|
434
429
|
exports.OemBrandingContextRuntime = OemBrandingContextRuntime;
|
|
435
430
|
exports.ParamsRuntime = ParamsRuntime;
|
|
436
431
|
exports.RestRuntime = RestRuntime;
|
|
432
|
+
exports.RouterRuntime = RouterRuntime;
|
|
437
433
|
exports.SiteRuntime = SiteRuntime;
|
|
438
434
|
exports.ToastRuntime = ToastRuntime;
|
|
439
435
|
exports.TokenRuntime = TokenRuntime;
|
|
440
436
|
exports.UserSubscriptionRuntime = UserSubscriptionRuntime;
|
|
437
|
+
exports.getCustomFieldValueForDisplayInUI = getCustomFieldValueForDisplayInUI;
|
|
441
438
|
exports.getCustomFieldValueToSaveFromRawValue = getCustomFieldValueToSaveFromRawValue;
|
|
442
439
|
exports.getDateValue = getDateValue;
|
|
443
440
|
exports.getHostConnector = getHostConnector;
|
|
444
441
|
exports.getStringValue = getStringValue;
|
|
442
|
+
exports.isValidCustomFieldValue = isValidCustomFieldValue;
|
|
445
443
|
exports.setupHostConnector = setupHostConnector;
|
|
446
444
|
Object.keys(irisAppRuntimeCoreApi).forEach(function (k) {
|
|
447
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 = {
|
|
@@ -322,10 +315,6 @@ const OemBrandingContextRuntime = {
|
|
|
322
315
|
};
|
|
323
316
|
|
|
324
317
|
const NavigationRuntime = {
|
|
325
|
-
setDeepLink: (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
326
|
-
const api = yield getHostConnector();
|
|
327
|
-
return api.setDeepLink(props);
|
|
328
|
-
}),
|
|
329
318
|
gotoAssetHome: (assetId, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
330
319
|
const api = yield getHostConnector();
|
|
331
320
|
return api.gotoAssetHome(assetId, options);
|
|
@@ -373,6 +362,13 @@ const RestRuntime = {
|
|
|
373
362
|
},
|
|
374
363
|
};
|
|
375
364
|
|
|
365
|
+
const RouterRuntime = {
|
|
366
|
+
getBasePath: () => {
|
|
367
|
+
var _a;
|
|
368
|
+
return `${((_a = document.getElementById("baseHref")) === null || _a === void 0 ? void 0 : _a.getAttribute("href")) || "<missing baseHref>"}${global.module}`;
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
376
372
|
const SiteRuntime = {
|
|
377
373
|
getSiteInfo: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
378
374
|
const api = yield getHostConnector();
|
|
@@ -416,4 +412,4 @@ const UserSubscriptionRuntime = {
|
|
|
416
412
|
}),
|
|
417
413
|
};
|
|
418
414
|
|
|
419
|
-
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;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { INavigationRuntime } from "@trackunit/iris-app-runtime-core-api";
|
|
2
|
-
|
|
3
|
-
export declare const NavigationRuntime: INavigationRuntime & {
|
|
4
|
-
setDeepLink: SetDeepLinkPromise;
|
|
5
|
-
};
|
|
2
|
+
export declare const NavigationRuntime: INavigationRuntime;
|
package/src/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./IrisOemManifestRuntime";
|
|
|
14
14
|
export * from "./NavigationRuntime";
|
|
15
15
|
export * from "./ParamsRuntime";
|
|
16
16
|
export * from "./RestRuntime";
|
|
17
|
+
export * from "./RouterRuntime";
|
|
17
18
|
export * from "./SiteRuntime";
|
|
18
19
|
export * from "./ToastRuntime";
|
|
19
20
|
export * from "./TokenRuntime";
|