@trackunit/react-table-helpers 1.0.18 → 1.0.19
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 +11 -16
- package/index.esm.js +11 -16
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -55,19 +55,18 @@ const setupLibraryTranslations = () => {
|
|
|
55
55
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
56
56
|
*/
|
|
57
57
|
const customFieldToCell = (customField, unitTranslation, unitPreference, language) => {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
59
58
|
const type = customField.type;
|
|
60
59
|
switch (type) {
|
|
61
60
|
case "BOOLEAN": {
|
|
62
|
-
const checked =
|
|
61
|
+
const checked = customField.booleanValue ?? false;
|
|
63
62
|
return jsxRuntime.jsx(reactTableBaseComponents.CheckboxCell, { checked: checked });
|
|
64
63
|
}
|
|
65
64
|
case "STRING":
|
|
66
|
-
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content:
|
|
65
|
+
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: customField.stringValue?.toString() ?? "" });
|
|
67
66
|
case "EMAIL":
|
|
68
67
|
case "PHONE_NUMBER":
|
|
69
68
|
case "WEB_ADDRESS": {
|
|
70
|
-
const link =
|
|
69
|
+
const link = customField.stringValue ?? "";
|
|
71
70
|
const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
|
|
72
71
|
return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: link, type: linkType });
|
|
73
72
|
}
|
|
@@ -77,11 +76,11 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
77
76
|
}
|
|
78
77
|
case "STRING_LIST":
|
|
79
78
|
case "DROPDOWN": {
|
|
80
|
-
const tags =
|
|
79
|
+
const tags = customField.stringArrayValue ?? [];
|
|
81
80
|
return jsxRuntime.jsx(reactTableBaseComponents.TagsCell, { tags: tags });
|
|
82
81
|
}
|
|
83
82
|
case "JSON":
|
|
84
|
-
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content:
|
|
83
|
+
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: customField.jsonValue?.toString() ?? "" });
|
|
85
84
|
case "NUMBER": {
|
|
86
85
|
const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
87
86
|
const value = customField.numberValue ? customField.numberValue + "" : undefined;
|
|
@@ -89,7 +88,7 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
89
88
|
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { unit: unitTranslation(unitType), value: updatedValue });
|
|
90
89
|
}
|
|
91
90
|
case "MONETARY":
|
|
92
|
-
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value:
|
|
91
|
+
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: customField.numberValue?.toString() ?? "" });
|
|
93
92
|
default:
|
|
94
93
|
return assertNever(type);
|
|
95
94
|
}
|
|
@@ -110,18 +109,14 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
110
109
|
return react.useMemo(() => {
|
|
111
110
|
const columnHelper = reactTable.createColumnHelper();
|
|
112
111
|
const result = [];
|
|
113
|
-
customFieldDefinitions
|
|
114
|
-
if (
|
|
112
|
+
customFieldDefinitions?.forEach(customFieldDefinition => {
|
|
113
|
+
if (customFieldDefinition?.node &&
|
|
115
114
|
customFieldDefinition.node.id &&
|
|
116
115
|
customFieldDefinition.node.title &&
|
|
117
116
|
customFieldDefinition.node.type) {
|
|
118
|
-
const column = columnHelper.accessor(data => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var _a, _b;
|
|
122
|
-
return ((_a = field === null || field === void 0 ? void 0 : field.node) === null || _a === void 0 ? void 0 : _a.definition.id) === ((_b = customFieldDefinition.node) === null || _b === void 0 ? void 0 : _b.id);
|
|
123
|
-
})) === null || _c === void 0 ? void 0 : _c.node;
|
|
124
|
-
}, {
|
|
117
|
+
const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
|
|
118
|
+
return field?.node?.definition.id === customFieldDefinition.node?.id;
|
|
119
|
+
})?.node, {
|
|
125
120
|
header: customFieldDefinition.node.title,
|
|
126
121
|
id: customFieldDefinition.node.id,
|
|
127
122
|
enableSorting: customFieldDefinition.node.type !== "DROPDOWN",
|
package/index.esm.js
CHANGED
|
@@ -53,19 +53,18 @@ const setupLibraryTranslations = () => {
|
|
|
53
53
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
54
54
|
*/
|
|
55
55
|
const customFieldToCell = (customField, unitTranslation, unitPreference, language) => {
|
|
56
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
57
56
|
const type = customField.type;
|
|
58
57
|
switch (type) {
|
|
59
58
|
case "BOOLEAN": {
|
|
60
|
-
const checked =
|
|
59
|
+
const checked = customField.booleanValue ?? false;
|
|
61
60
|
return jsx(CheckboxCell, { checked: checked });
|
|
62
61
|
}
|
|
63
62
|
case "STRING":
|
|
64
|
-
return jsx(TextCell, { content:
|
|
63
|
+
return jsx(TextCell, { content: customField.stringValue?.toString() ?? "" });
|
|
65
64
|
case "EMAIL":
|
|
66
65
|
case "PHONE_NUMBER":
|
|
67
66
|
case "WEB_ADDRESS": {
|
|
68
|
-
const link =
|
|
67
|
+
const link = customField.stringValue ?? "";
|
|
69
68
|
const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
|
|
70
69
|
return jsx(LinkCell, { link: link, type: linkType });
|
|
71
70
|
}
|
|
@@ -75,11 +74,11 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
75
74
|
}
|
|
76
75
|
case "STRING_LIST":
|
|
77
76
|
case "DROPDOWN": {
|
|
78
|
-
const tags =
|
|
77
|
+
const tags = customField.stringArrayValue ?? [];
|
|
79
78
|
return jsx(TagsCell, { tags: tags });
|
|
80
79
|
}
|
|
81
80
|
case "JSON":
|
|
82
|
-
return jsx(TextCell, { content:
|
|
81
|
+
return jsx(TextCell, { content: customField.jsonValue?.toString() ?? "" });
|
|
83
82
|
case "NUMBER": {
|
|
84
83
|
const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
85
84
|
const value = customField.numberValue ? customField.numberValue + "" : undefined;
|
|
@@ -87,7 +86,7 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
87
86
|
return jsx(NumberCell, { unit: unitTranslation(unitType), value: updatedValue });
|
|
88
87
|
}
|
|
89
88
|
case "MONETARY":
|
|
90
|
-
return jsx(NumberCell, { value:
|
|
89
|
+
return jsx(NumberCell, { value: customField.numberValue?.toString() ?? "" });
|
|
91
90
|
default:
|
|
92
91
|
return assertNever(type);
|
|
93
92
|
}
|
|
@@ -108,18 +107,14 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
108
107
|
return useMemo(() => {
|
|
109
108
|
const columnHelper = createColumnHelper();
|
|
110
109
|
const result = [];
|
|
111
|
-
customFieldDefinitions
|
|
112
|
-
if (
|
|
110
|
+
customFieldDefinitions?.forEach(customFieldDefinition => {
|
|
111
|
+
if (customFieldDefinition?.node &&
|
|
113
112
|
customFieldDefinition.node.id &&
|
|
114
113
|
customFieldDefinition.node.title &&
|
|
115
114
|
customFieldDefinition.node.type) {
|
|
116
|
-
const column = columnHelper.accessor(data => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var _a, _b;
|
|
120
|
-
return ((_a = field === null || field === void 0 ? void 0 : field.node) === null || _a === void 0 ? void 0 : _a.definition.id) === ((_b = customFieldDefinition.node) === null || _b === void 0 ? void 0 : _b.id);
|
|
121
|
-
})) === null || _c === void 0 ? void 0 : _c.node;
|
|
122
|
-
}, {
|
|
115
|
+
const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
|
|
116
|
+
return field?.node?.definition.id === customFieldDefinition.node?.id;
|
|
117
|
+
})?.node, {
|
|
123
118
|
header: customFieldDefinition.node.title,
|
|
124
119
|
id: customFieldDefinition.node.id,
|
|
125
120
|
enableSorting: customFieldDefinition.node.type !== "DROPDOWN",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"react": "18.3.1",
|
|
11
11
|
"@js-temporal/polyfill": "^0.4.4",
|
|
12
12
|
"@trackunit/i18n-library-translation": "^1.0.7",
|
|
13
|
-
"@trackunit/custom-field-components": "^1.0.
|
|
13
|
+
"@trackunit/custom-field-components": "^1.0.18",
|
|
14
14
|
"@trackunit/iris-app-runtime-core": "^1.0.5",
|
|
15
15
|
"@trackunit/react-core-contexts-api": "^1.0.5",
|
|
16
16
|
"@trackunit/react-table-base-components": "^1.0.16",
|