@trackunit/react-table-helpers 1.16.7 → 1.16.8-alpha-6c7c4fa43b0.0
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 +18 -1
- package/index.esm.js +20 -3
- package/package.json +13 -13
- package/src/useColumnDefinitionsFromCustomFieldDefinition/customFieldToCell.d.ts +1 -1
- package/src/useColumnDefinitionsFromCustomFieldDefinition/customFieldToExportString.d.ts +1 -1
- package/src/useColumnDefinitionsFromCustomFieldDefinition/types.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -148,6 +148,20 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
148
148
|
}
|
|
149
149
|
case "MonetaryFieldValueAndDefinition":
|
|
150
150
|
return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: customField.monetaryValue?.toString() ?? "" });
|
|
151
|
+
case "FileFieldValueAndDefinition": {
|
|
152
|
+
const fileName = customField.fileName;
|
|
153
|
+
const downloadLink = customField.downloadLink;
|
|
154
|
+
if (!fileName) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
if (!downloadLink) {
|
|
158
|
+
return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: fileName });
|
|
159
|
+
}
|
|
160
|
+
const handleClick = event => {
|
|
161
|
+
event.stopPropagation();
|
|
162
|
+
};
|
|
163
|
+
return (jsxRuntime.jsx(reactComponents.ExternalLink, { color: "neutral", href: downloadLink, onClick: handleClick, title: fileName, children: fileName }));
|
|
164
|
+
}
|
|
151
165
|
default:
|
|
152
166
|
throw new Error(`Unexpected value: ${type}`);
|
|
153
167
|
}
|
|
@@ -191,6 +205,8 @@ const customFieldToExportString = (customField, unitTranslation, unitPreference,
|
|
|
191
205
|
}
|
|
192
206
|
case "MonetaryFieldValueAndDefinition":
|
|
193
207
|
return customField.monetaryValue?.toString() ?? "";
|
|
208
|
+
case "FileFieldValueAndDefinition":
|
|
209
|
+
return customField.fileName ?? "";
|
|
194
210
|
default:
|
|
195
211
|
throw new Error(`Unexpected value: ${type}`);
|
|
196
212
|
}
|
|
@@ -454,7 +470,8 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
454
470
|
header: customFieldDefinition.node.title,
|
|
455
471
|
id: customFieldDefinition.node.id,
|
|
456
472
|
enableSorting: customFieldDefinition.node.__typename !== "DropDownFieldDefinition" &&
|
|
457
|
-
customFieldDefinition.node.__typename !== "StringListFieldDefinition"
|
|
473
|
+
customFieldDefinition.node.__typename !== "StringListFieldDefinition" &&
|
|
474
|
+
customFieldDefinition.node.__typename !== "FileFieldDefinition",
|
|
458
475
|
meta: {
|
|
459
476
|
fragment: AssetCustomFieldsFragmentDoc,
|
|
460
477
|
hiddenByDefault: true,
|
package/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { Button } from '@trackunit/react-components';
|
|
3
|
+
import { Button, ExternalLink } from '@trackunit/react-components';
|
|
4
4
|
import { useExportDataContext } from '@trackunit/react-core-hooks';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { Temporal } from '@js-temporal/polyfill';
|
|
7
7
|
import { getCustomFieldValueForDisplayInUI } from '@trackunit/iris-app-runtime-core';
|
|
8
|
-
import {
|
|
8
|
+
import { TextCell, NumberCell, TagsCell, PlainDateCell, LinkCell, CheckboxCell } from '@trackunit/react-table-base-components';
|
|
9
9
|
import { useUnitTranslation } from '@trackunit/custom-field-components';
|
|
10
10
|
import { CustomFieldPrefix } from '@trackunit/filters-graphql-hook';
|
|
11
11
|
import { createColumnHelper } from '@trackunit/react-table';
|
|
@@ -146,6 +146,20 @@ const customFieldToCell = (customField, unitTranslation, unitPreference, languag
|
|
|
146
146
|
}
|
|
147
147
|
case "MonetaryFieldValueAndDefinition":
|
|
148
148
|
return jsx(NumberCell, { value: customField.monetaryValue?.toString() ?? "" });
|
|
149
|
+
case "FileFieldValueAndDefinition": {
|
|
150
|
+
const fileName = customField.fileName;
|
|
151
|
+
const downloadLink = customField.downloadLink;
|
|
152
|
+
if (!fileName) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
if (!downloadLink) {
|
|
156
|
+
return jsx(TextCell, { content: fileName });
|
|
157
|
+
}
|
|
158
|
+
const handleClick = event => {
|
|
159
|
+
event.stopPropagation();
|
|
160
|
+
};
|
|
161
|
+
return (jsx(ExternalLink, { color: "neutral", href: downloadLink, onClick: handleClick, title: fileName, children: fileName }));
|
|
162
|
+
}
|
|
149
163
|
default:
|
|
150
164
|
throw new Error(`Unexpected value: ${type}`);
|
|
151
165
|
}
|
|
@@ -189,6 +203,8 @@ const customFieldToExportString = (customField, unitTranslation, unitPreference,
|
|
|
189
203
|
}
|
|
190
204
|
case "MonetaryFieldValueAndDefinition":
|
|
191
205
|
return customField.monetaryValue?.toString() ?? "";
|
|
206
|
+
case "FileFieldValueAndDefinition":
|
|
207
|
+
return customField.fileName ?? "";
|
|
192
208
|
default:
|
|
193
209
|
throw new Error(`Unexpected value: ${type}`);
|
|
194
210
|
}
|
|
@@ -452,7 +468,8 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
|
|
|
452
468
|
header: customFieldDefinition.node.title,
|
|
453
469
|
id: customFieldDefinition.node.id,
|
|
454
470
|
enableSorting: customFieldDefinition.node.__typename !== "DropDownFieldDefinition" &&
|
|
455
|
-
customFieldDefinition.node.__typename !== "StringListFieldDefinition"
|
|
471
|
+
customFieldDefinition.node.__typename !== "StringListFieldDefinition" &&
|
|
472
|
+
customFieldDefinition.node.__typename !== "FileFieldDefinition",
|
|
456
473
|
meta: {
|
|
457
474
|
fragment: AssetCustomFieldsFragmentDoc,
|
|
458
475
|
hiddenByDefault: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-helpers",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.8-alpha-6c7c4fa43b0.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
|
-
"@trackunit/filters-filter-bar": "1.15.
|
|
12
|
-
"@trackunit/filters-graphql-hook": "1.18.
|
|
13
|
-
"@trackunit/i18n-library-translation": "1.12.
|
|
14
|
-
"@trackunit/custom-field-components": "1.14.
|
|
15
|
-
"@trackunit/iris-app-runtime-core": "1.13.
|
|
16
|
-
"@trackunit/iris-app-runtime-core-api": "1.12.
|
|
17
|
-
"@trackunit/react-table-base-components": "1.14.
|
|
18
|
-
"@trackunit/react-table": "1.14.
|
|
11
|
+
"@trackunit/filters-filter-bar": "1.15.7-alpha-6c7c4fa43b0.0",
|
|
12
|
+
"@trackunit/filters-graphql-hook": "1.18.7-alpha-6c7c4fa43b0.0",
|
|
13
|
+
"@trackunit/i18n-library-translation": "1.12.55-alpha-6c7c4fa43b0.0",
|
|
14
|
+
"@trackunit/custom-field-components": "1.14.7-alpha-6c7c4fa43b0.0",
|
|
15
|
+
"@trackunit/iris-app-runtime-core": "1.13.49-alpha-6c7c4fa43b0.0",
|
|
16
|
+
"@trackunit/iris-app-runtime-core-api": "1.12.47-alpha-6c7c4fa43b0.0",
|
|
17
|
+
"@trackunit/react-table-base-components": "1.14.4-alpha-6c7c4fa43b0.0",
|
|
18
|
+
"@trackunit/react-table": "1.14.8-alpha-6c7c4fa43b0.0",
|
|
19
19
|
"@js-temporal/polyfill": "^0.5.1",
|
|
20
20
|
"@tanstack/react-table": "^8.20.6",
|
|
21
|
-
"@trackunit/react-components": "1.18.
|
|
22
|
-
"@trackunit/react-core-hooks": "1.12.
|
|
23
|
-
"@trackunit/react-graphql-hooks": "1.15.
|
|
24
|
-
"@trackunit/iris-app-api": "1.14.
|
|
21
|
+
"@trackunit/react-components": "1.18.4-alpha-6c7c4fa43b0.0",
|
|
22
|
+
"@trackunit/react-core-hooks": "1.12.52-alpha-6c7c4fa43b0.0",
|
|
23
|
+
"@trackunit/react-graphql-hooks": "1.15.7-alpha-6c7c4fa43b0.0",
|
|
24
|
+
"@trackunit/iris-app-api": "1.14.67-alpha-6c7c4fa43b0.0",
|
|
25
25
|
"@graphql-codegen/cli": "^5.0.3",
|
|
26
26
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
27
27
|
"graphql": "^16.10.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
1
|
import { UnitType } from "@trackunit/custom-field-components";
|
|
3
2
|
import { SystemOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
4
|
import { CustomFieldData } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnitType } from "@trackunit/custom-field-components";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
2
|
import { SystemOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
4
|
import { CustomFieldData } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
@@ -133,6 +133,7 @@ export type CustomFieldData = {
|
|
|
133
133
|
valueId?: string | null;
|
|
134
134
|
fileId?: string | null;
|
|
135
135
|
fileName?: string | null;
|
|
136
|
+
downloadLink?: string | null;
|
|
136
137
|
__typename?: "FileFieldValueAndDefinition";
|
|
137
138
|
definition: {
|
|
138
139
|
__typename?: "FileFieldDefinition";
|