@trackunit/react-table-helpers 0.0.37 → 0.0.40
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
|
@@ -52,16 +52,13 @@ const setupLibraryTranslations = () => {
|
|
|
52
52
|
i18nLibraryTranslation.registerTranslations(translations);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const extractNumberAsString = (value, unitPreference, unitSi, unitUs, language) => {
|
|
56
|
-
const unit = unitPreference === "SI" ? unitSi : unitUs;
|
|
57
|
-
const updatedValue = irisAppRuntimeCore.CustomFieldRuntime.getCustomFieldValueForDisplayInUI(value, unit, unitPreference, language);
|
|
58
|
-
return `${updatedValue}${unit && updatedValue ? " " + unit : ""}`;
|
|
59
|
-
};
|
|
60
55
|
/**
|
|
61
56
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
62
57
|
*/
|
|
63
|
-
const customFieldToCell = (customField, unitPreference, language
|
|
64
|
-
|
|
58
|
+
const customFieldToCell = (customField, unitPreference, language
|
|
59
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
60
|
+
) => {
|
|
61
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
65
62
|
const type = customField.type;
|
|
66
63
|
switch (type) {
|
|
67
64
|
case "BOOLEAN": {
|
|
@@ -69,7 +66,7 @@ const customFieldToCell = (customField, unitPreference, language) => {
|
|
|
69
66
|
return jsxRuntime.jsx(reactTableBaseComponents.CheckboxCell, { checked: checked });
|
|
70
67
|
}
|
|
71
68
|
case "STRING":
|
|
72
|
-
return (_c = (_b = customField.stringValue) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
|
|
69
|
+
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: (_c = (_b = customField.stringValue) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "" });
|
|
73
70
|
case "EMAIL":
|
|
74
71
|
case "PHONE_NUMBER":
|
|
75
72
|
case "WEB_ADDRESS": {
|
|
@@ -77,20 +74,24 @@ const customFieldToCell = (customField, unitPreference, language) => {
|
|
|
77
74
|
const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
|
|
78
75
|
return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: link, type: linkType });
|
|
79
76
|
}
|
|
80
|
-
case "DATE":
|
|
81
|
-
|
|
77
|
+
case "DATE": {
|
|
78
|
+
const date = customField.dateValue;
|
|
79
|
+
return date ? jsxRuntime.jsx(reactTableBaseComponents.DateTimeCell, { date: new Date(date) }) : null;
|
|
80
|
+
}
|
|
82
81
|
case "DROPDOWN": {
|
|
83
|
-
const tags = (
|
|
82
|
+
const tags = (_e = customField.stringArrayValue) !== null && _e !== void 0 ? _e : [];
|
|
84
83
|
return jsxRuntime.jsx(reactTableBaseComponents.TagsCell, { tags: tags });
|
|
85
84
|
}
|
|
86
85
|
case "JSON":
|
|
87
|
-
return (
|
|
86
|
+
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: (_g = (_f = customField.jsonValue) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : "" });
|
|
88
87
|
case "NUMBER": {
|
|
88
|
+
const unit = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
89
89
|
const value = customField.numberValue ? customField.numberValue + "" : undefined;
|
|
90
|
-
|
|
90
|
+
const updatedValue = irisAppRuntimeCore.CustomFieldRuntime.getCustomFieldValueForDisplayInUI(value, unit, unitPreference, language);
|
|
91
|
+
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: updatedValue, unit: unit });
|
|
91
92
|
}
|
|
92
93
|
case "MONETARY":
|
|
93
|
-
return (
|
|
94
|
+
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: (_j = (_h = customField.numberValue) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : "" });
|
|
94
95
|
default:
|
|
95
96
|
return assertNever(type);
|
|
96
97
|
}
|
package/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CustomFieldType } from '@trackunit/iris-app-runtime-core-api';
|
|
|
4
4
|
import { createColumnHelper } from '@trackunit/react-table';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { CustomFieldRuntime } from '@trackunit/iris-app-runtime-core';
|
|
7
|
-
import { TagsCell, LinkCell, CheckboxCell } from '@trackunit/react-table-base-components';
|
|
7
|
+
import { NumberCell, TextCell, TagsCell, DateTimeCell, LinkCell, CheckboxCell } from '@trackunit/react-table-base-components';
|
|
8
8
|
|
|
9
9
|
var defaultTranslations = {
|
|
10
10
|
|
|
@@ -48,16 +48,13 @@ const setupLibraryTranslations = () => {
|
|
|
48
48
|
registerTranslations(translations);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const extractNumberAsString = (value, unitPreference, unitSi, unitUs, language) => {
|
|
52
|
-
const unit = unitPreference === "SI" ? unitSi : unitUs;
|
|
53
|
-
const updatedValue = CustomFieldRuntime.getCustomFieldValueForDisplayInUI(value, unit, unitPreference, language);
|
|
54
|
-
return `${updatedValue}${unit && updatedValue ? " " + unit : ""}`;
|
|
55
|
-
};
|
|
56
51
|
/**
|
|
57
52
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
58
53
|
*/
|
|
59
|
-
const customFieldToCell = (customField, unitPreference, language
|
|
60
|
-
|
|
54
|
+
const customFieldToCell = (customField, unitPreference, language
|
|
55
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
56
|
+
) => {
|
|
57
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
61
58
|
const type = customField.type;
|
|
62
59
|
switch (type) {
|
|
63
60
|
case "BOOLEAN": {
|
|
@@ -65,7 +62,7 @@ const customFieldToCell = (customField, unitPreference, language) => {
|
|
|
65
62
|
return jsx(CheckboxCell, { checked: checked });
|
|
66
63
|
}
|
|
67
64
|
case "STRING":
|
|
68
|
-
return (_c = (_b = customField.stringValue) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
|
|
65
|
+
return jsx(TextCell, { content: (_c = (_b = customField.stringValue) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "" });
|
|
69
66
|
case "EMAIL":
|
|
70
67
|
case "PHONE_NUMBER":
|
|
71
68
|
case "WEB_ADDRESS": {
|
|
@@ -73,20 +70,24 @@ const customFieldToCell = (customField, unitPreference, language) => {
|
|
|
73
70
|
const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
|
|
74
71
|
return jsx(LinkCell, { link: link, type: linkType });
|
|
75
72
|
}
|
|
76
|
-
case "DATE":
|
|
77
|
-
|
|
73
|
+
case "DATE": {
|
|
74
|
+
const date = customField.dateValue;
|
|
75
|
+
return date ? jsx(DateTimeCell, { date: new Date(date) }) : null;
|
|
76
|
+
}
|
|
78
77
|
case "DROPDOWN": {
|
|
79
|
-
const tags = (
|
|
78
|
+
const tags = (_e = customField.stringArrayValue) !== null && _e !== void 0 ? _e : [];
|
|
80
79
|
return jsx(TagsCell, { tags: tags });
|
|
81
80
|
}
|
|
82
81
|
case "JSON":
|
|
83
|
-
return (
|
|
82
|
+
return jsx(TextCell, { content: (_g = (_f = customField.jsonValue) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : "" });
|
|
84
83
|
case "NUMBER": {
|
|
84
|
+
const unit = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
85
85
|
const value = customField.numberValue ? customField.numberValue + "" : undefined;
|
|
86
|
-
|
|
86
|
+
const updatedValue = CustomFieldRuntime.getCustomFieldValueForDisplayInUI(value, unit, unitPreference, language);
|
|
87
|
+
return jsx(NumberCell, { value: updatedValue, unit: unit });
|
|
87
88
|
}
|
|
88
89
|
case "MONETARY":
|
|
89
|
-
return (
|
|
90
|
+
return jsx(NumberCell, { value: (_j = (_h = customField.numberValue) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : "" });
|
|
90
91
|
default:
|
|
91
92
|
return assertNever(type);
|
|
92
93
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
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
|
"dependencies": {
|
|
10
|
-
"@trackunit/i18n-library-translation": "0.0.
|
|
11
|
-
"@trackunit/iris-app-runtime-core": "0.3.
|
|
12
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.
|
|
13
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
14
|
-
"@trackunit/react-core-contexts-test": "0.1.
|
|
15
|
-
"@trackunit/react-table": "0.0.
|
|
16
|
-
"@trackunit/react-table-base-components": "0.0.
|
|
10
|
+
"@trackunit/i18n-library-translation": "0.0.81",
|
|
11
|
+
"@trackunit/iris-app-runtime-core": "0.3.81",
|
|
12
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.73",
|
|
13
|
+
"@trackunit/react-core-contexts-api": "0.2.61",
|
|
14
|
+
"@trackunit/react-core-contexts-test": "0.1.115",
|
|
15
|
+
"@trackunit/react-table": "0.0.46",
|
|
16
|
+
"@trackunit/react-table-base-components": "0.0.33",
|
|
17
17
|
"react": "18.2.0"
|
|
18
18
|
},
|
|
19
19
|
"module": "./index.esm.js",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SystemOfMeasurementType } from "@trackunit/react-core-contexts-api";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
2
|
import { CustomFieldData } from "./types";
|
|
4
3
|
/**
|
|
5
4
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
6
5
|
*/
|
|
7
|
-
export declare const customFieldToCell: (customField: CustomFieldData, unitPreference?: SystemOfMeasurementType, language?: string) => ReactNode;
|
|
6
|
+
export declare const customFieldToCell: (customField: CustomFieldData, unitPreference?: SystemOfMeasurementType, language?: string) => React.ReactNode;
|