@trackunit/react-table-helpers 0.0.1-alpha-c761039087.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.
Files changed (44) hide show
  1. package/README.md +22 -0
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.js +139 -0
  4. package/index.esm.js +135 -0
  5. package/package.json +19 -0
  6. package/src/index.d.ts +1 -0
  7. package/src/translation.d.ts +34 -0
  8. package/src/useColumnDefinitionsFromCustomFieldDefinition/customFiledToTableCell.d.ts +5 -0
  9. package/src/useColumnDefinitionsFromCustomFieldDefinition/types.d.ts +140 -0
  10. package/src/useColumnDefinitionsFromCustomFieldDefinition/useColumnDefinitionsFromCustomFieldDefinition.d.ts +13 -0
  11. package/translation.cjs.js +7 -0
  12. package/translation.cjs10.js +7 -0
  13. package/translation.cjs11.js +7 -0
  14. package/translation.cjs12.js +7 -0
  15. package/translation.cjs13.js +7 -0
  16. package/translation.cjs14.js +7 -0
  17. package/translation.cjs15.js +7 -0
  18. package/translation.cjs16.js +7 -0
  19. package/translation.cjs17.js +7 -0
  20. package/translation.cjs2.js +7 -0
  21. package/translation.cjs3.js +7 -0
  22. package/translation.cjs4.js +7 -0
  23. package/translation.cjs5.js +7 -0
  24. package/translation.cjs6.js +7 -0
  25. package/translation.cjs7.js +7 -0
  26. package/translation.cjs8.js +7 -0
  27. package/translation.cjs9.js +7 -0
  28. package/translation.esm.js +5 -0
  29. package/translation.esm10.js +5 -0
  30. package/translation.esm11.js +5 -0
  31. package/translation.esm12.js +5 -0
  32. package/translation.esm13.js +5 -0
  33. package/translation.esm14.js +5 -0
  34. package/translation.esm15.js +5 -0
  35. package/translation.esm16.js +5 -0
  36. package/translation.esm17.js +5 -0
  37. package/translation.esm2.js +5 -0
  38. package/translation.esm3.js +5 -0
  39. package/translation.esm4.js +5 -0
  40. package/translation.esm5.js +5 -0
  41. package/translation.esm6.js +5 -0
  42. package/translation.esm7.js +5 -0
  43. package/translation.esm8.js +5 -0
  44. package/translation.esm9.js +5 -0
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit React Table Helpers
6
+ The `@trackunit/react-table-helpers` package is part of Trackunits public UI library. It contains helper functions and hook used for the Table library.
7
+
8
+ This library is exposed publicly for use in the the Trackunit [Iris App SDK](https://www.npmjs.com/package/@trackunit/iris-app).
9
+
10
+ To browse all available components visit our [Public Storybook](https://developers.trackunit.com/page/ui-components).
11
+
12
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
13
+
14
+ ## Development
15
+ At this point this library is only developed by Trackunit Employees.
16
+ For development related information see the [development readme](https://github.com/Trackunit/manager/blob/master/libs/react/components/DEVELOPMENT.md).
17
+
18
+ ## Trackunit
19
+ This package was developed by Trackunit ApS.
20
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
21
+
22
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,139 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
7
+ var reactTable = require('@trackunit/react-table');
8
+ var react = require('react');
9
+ var reactTableBaseComponents = require('@trackunit/react-table-base-components');
10
+
11
+ var defaultTranslations = {
12
+
13
+ };
14
+
15
+ /** The translation namespace for this library */
16
+ const namespace = "react.table-helpers";
17
+ /**
18
+ * The TranslationResource for this Library.
19
+ * Holds lazy loaded imports for all languages supported by the library.
20
+ *
21
+ * This is used to register the translations for this library before initializing i18next.
22
+ */
23
+ const translations = {
24
+ ns: namespace,
25
+ default: defaultTranslations,
26
+ languages: {
27
+ de: () => Promise.resolve().then(function () { return require('./translation.cjs.js'); }),
28
+ da: () => Promise.resolve().then(function () { return require('./translation.cjs2.js'); }),
29
+ cs: () => Promise.resolve().then(function () { return require('./translation.cjs3.js'); }),
30
+ nl: () => Promise.resolve().then(function () { return require('./translation.cjs4.js'); }),
31
+ fr: () => Promise.resolve().then(function () { return require('./translation.cjs5.js'); }),
32
+ fi: () => Promise.resolve().then(function () { return require('./translation.cjs6.js'); }),
33
+ hu: () => Promise.resolve().then(function () { return require('./translation.cjs7.js'); }),
34
+ it: () => Promise.resolve().then(function () { return require('./translation.cjs8.js'); }),
35
+ nb: () => Promise.resolve().then(function () { return require('./translation.cjs9.js'); }),
36
+ pl: () => Promise.resolve().then(function () { return require('./translation.cjs10.js'); }),
37
+ pt: () => Promise.resolve().then(function () { return require('./translation.cjs11.js'); }),
38
+ ru: () => Promise.resolve().then(function () { return require('./translation.cjs12.js'); }),
39
+ ro: () => Promise.resolve().then(function () { return require('./translation.cjs13.js'); }),
40
+ es: () => Promise.resolve().then(function () { return require('./translation.cjs14.js'); }),
41
+ sv: () => Promise.resolve().then(function () { return require('./translation.cjs15.js'); }),
42
+ ja: () => Promise.resolve().then(function () { return require('./translation.cjs16.js'); }),
43
+ th: () => Promise.resolve().then(function () { return require('./translation.cjs17.js'); }),
44
+ },
45
+ };
46
+ /**
47
+ * Registers the translations for this library
48
+ */
49
+ const setupLibraryTranslations = () => {
50
+ i18nLibraryTranslation.registerTranslations(translations);
51
+ };
52
+
53
+ /**
54
+ * Takes a custom fields data object and returns a react node that can be used as a cell in a table.
55
+ */
56
+ const customFieldToCell = (customField) => {
57
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
58
+ const type = customField.type;
59
+ switch (type) {
60
+ case "BOOLEAN": {
61
+ const checked = (_b = (_a = customField.booleanValue) !== null && _a !== void 0 ? _a : customField.definition.defaultBooleanValue) !== null && _b !== void 0 ? _b : false;
62
+ return jsxRuntime.jsx(reactTableBaseComponents.CheckboxCell, { checked: checked });
63
+ }
64
+ case "STRING":
65
+ return (_f = (_d = (_c = customField.stringValue) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : (_e = customField.definition.defaultStringValue) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : "";
66
+ case "EMAIL":
67
+ case "PHONE_NUMBER":
68
+ case "WEB_ADDRESS": {
69
+ const link = (_h = (_g = customField.stringValue) !== null && _g !== void 0 ? _g : customField.definition.defaultStringValue) !== null && _h !== void 0 ? _h : "";
70
+ const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
71
+ return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: link, type: linkType });
72
+ }
73
+ case "DATE":
74
+ return (_m = (_k = (_j = customField.dateValue) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : (_l = customField.definition.defaultDateValue) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : "";
75
+ case "DROPDOWN": {
76
+ const tags = (_p = (_o = customField.stringArrayValue) !== null && _o !== void 0 ? _o : customField.definition.defaultStringArrayValue) !== null && _p !== void 0 ? _p : [];
77
+ return jsxRuntime.jsx(reactTableBaseComponents.TagsCell, { tags: tags });
78
+ }
79
+ case "JSON":
80
+ return (_t = (_r = (_q = customField.jsonValue) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : (_s = customField.definition.defaultJsonValue) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : "";
81
+ case "NUMBER":
82
+ case "MONETARY":
83
+ return (_x = (_v = (_u = customField.numberValue) === null || _u === void 0 ? void 0 : _u.toString()) !== null && _v !== void 0 ? _v : (_w = customField.definition.defaultNumberValue) === null || _w === void 0 ? void 0 : _w.toString()) !== null && _x !== void 0 ? _x : "";
84
+ default:
85
+ return assertNever(type);
86
+ }
87
+ };
88
+ function assertNever(value) {
89
+ throw new Error(`Unexpected value: ${value}`);
90
+ }
91
+
92
+ /**
93
+ * Generates an array of table column definitions based on custom field definitions.
94
+ *
95
+ * @template TDataType - The data type with custom fields.
96
+ * @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
97
+ * @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
98
+ */
99
+ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, }) => {
100
+ return react.useMemo(() => {
101
+ const columnHelper = reactTable.createColumnHelper();
102
+ const result = [];
103
+ customFieldDefinitions === null || customFieldDefinitions === void 0 ? void 0 : customFieldDefinitions.forEach(customFieldDefinition => {
104
+ if ((customFieldDefinition === null || customFieldDefinition === void 0 ? void 0 : customFieldDefinition.node) &&
105
+ customFieldDefinition.node.definitionId &&
106
+ customFieldDefinition.node.title &&
107
+ customFieldDefinition.node.type) {
108
+ const column = columnHelper.accessor(data => {
109
+ var _a, _b, _c;
110
+ return (_c = (_b = (_a = data.customFields) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b.find(field => { var _a, _b; return ((_a = field === null || field === void 0 ? void 0 : field.node) === null || _a === void 0 ? void 0 : _a.definition.definitionId) === ((_b = customFieldDefinition.node) === null || _b === void 0 ? void 0 : _b.definitionId); })) === null || _c === void 0 ? void 0 : _c.node;
111
+ }, {
112
+ header: customFieldDefinition.node.title,
113
+ id: customFieldDefinition.node.definitionId,
114
+ enableSorting: false,
115
+ meta: {
116
+ hiddenByDefault: true,
117
+ },
118
+ cell: cell => {
119
+ const cellValue = cell.getValue();
120
+ return cellValue ? customFieldToCell(cellValue) : "";
121
+ },
122
+ });
123
+ result.push(column);
124
+ }
125
+ });
126
+ return result;
127
+ }, [customFieldDefinitions]);
128
+ };
129
+
130
+ /*
131
+ * ----------------------------
132
+ * | SETUP TRANSLATIONS START |
133
+ * ----------------------------
134
+ * This import and function call is needed to register translations for this library.
135
+ * Do not remove this if this library has translations.
136
+ */
137
+ setupLibraryTranslations();
138
+
139
+ exports.useColumnDefinitionsFromCustomFieldDefinition = useColumnDefinitionsFromCustomFieldDefinition;
package/index.esm.js ADDED
@@ -0,0 +1,135 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { registerTranslations } from '@trackunit/i18n-library-translation';
3
+ import { createColumnHelper } from '@trackunit/react-table';
4
+ import { useMemo } from 'react';
5
+ import { TagsCell, LinkCell, CheckboxCell } from '@trackunit/react-table-base-components';
6
+
7
+ var defaultTranslations = {
8
+
9
+ };
10
+
11
+ /** The translation namespace for this library */
12
+ const namespace = "react.table-helpers";
13
+ /**
14
+ * The TranslationResource for this Library.
15
+ * Holds lazy loaded imports for all languages supported by the library.
16
+ *
17
+ * This is used to register the translations for this library before initializing i18next.
18
+ */
19
+ const translations = {
20
+ ns: namespace,
21
+ default: defaultTranslations,
22
+ languages: {
23
+ de: () => import('./translation.esm.js'),
24
+ da: () => import('./translation.esm2.js'),
25
+ cs: () => import('./translation.esm3.js'),
26
+ nl: () => import('./translation.esm4.js'),
27
+ fr: () => import('./translation.esm5.js'),
28
+ fi: () => import('./translation.esm6.js'),
29
+ hu: () => import('./translation.esm7.js'),
30
+ it: () => import('./translation.esm8.js'),
31
+ nb: () => import('./translation.esm9.js'),
32
+ pl: () => import('./translation.esm10.js'),
33
+ pt: () => import('./translation.esm11.js'),
34
+ ru: () => import('./translation.esm12.js'),
35
+ ro: () => import('./translation.esm13.js'),
36
+ es: () => import('./translation.esm14.js'),
37
+ sv: () => import('./translation.esm15.js'),
38
+ ja: () => import('./translation.esm16.js'),
39
+ th: () => import('./translation.esm17.js'),
40
+ },
41
+ };
42
+ /**
43
+ * Registers the translations for this library
44
+ */
45
+ const setupLibraryTranslations = () => {
46
+ registerTranslations(translations);
47
+ };
48
+
49
+ /**
50
+ * Takes a custom fields data object and returns a react node that can be used as a cell in a table.
51
+ */
52
+ const customFieldToCell = (customField) => {
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
54
+ const type = customField.type;
55
+ switch (type) {
56
+ case "BOOLEAN": {
57
+ const checked = (_b = (_a = customField.booleanValue) !== null && _a !== void 0 ? _a : customField.definition.defaultBooleanValue) !== null && _b !== void 0 ? _b : false;
58
+ return jsx(CheckboxCell, { checked: checked });
59
+ }
60
+ case "STRING":
61
+ return (_f = (_d = (_c = customField.stringValue) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : (_e = customField.definition.defaultStringValue) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : "";
62
+ case "EMAIL":
63
+ case "PHONE_NUMBER":
64
+ case "WEB_ADDRESS": {
65
+ const link = (_h = (_g = customField.stringValue) !== null && _g !== void 0 ? _g : customField.definition.defaultStringValue) !== null && _h !== void 0 ? _h : "";
66
+ const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
67
+ return jsx(LinkCell, { link: link, type: linkType });
68
+ }
69
+ case "DATE":
70
+ return (_m = (_k = (_j = customField.dateValue) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : (_l = customField.definition.defaultDateValue) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : "";
71
+ case "DROPDOWN": {
72
+ const tags = (_p = (_o = customField.stringArrayValue) !== null && _o !== void 0 ? _o : customField.definition.defaultStringArrayValue) !== null && _p !== void 0 ? _p : [];
73
+ return jsx(TagsCell, { tags: tags });
74
+ }
75
+ case "JSON":
76
+ return (_t = (_r = (_q = customField.jsonValue) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : (_s = customField.definition.defaultJsonValue) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : "";
77
+ case "NUMBER":
78
+ case "MONETARY":
79
+ return (_x = (_v = (_u = customField.numberValue) === null || _u === void 0 ? void 0 : _u.toString()) !== null && _v !== void 0 ? _v : (_w = customField.definition.defaultNumberValue) === null || _w === void 0 ? void 0 : _w.toString()) !== null && _x !== void 0 ? _x : "";
80
+ default:
81
+ return assertNever(type);
82
+ }
83
+ };
84
+ function assertNever(value) {
85
+ throw new Error(`Unexpected value: ${value}`);
86
+ }
87
+
88
+ /**
89
+ * Generates an array of table column definitions based on custom field definitions.
90
+ *
91
+ * @template TDataType - The data type with custom fields.
92
+ * @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
93
+ * @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
94
+ */
95
+ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, }) => {
96
+ return useMemo(() => {
97
+ const columnHelper = createColumnHelper();
98
+ const result = [];
99
+ customFieldDefinitions === null || customFieldDefinitions === void 0 ? void 0 : customFieldDefinitions.forEach(customFieldDefinition => {
100
+ if ((customFieldDefinition === null || customFieldDefinition === void 0 ? void 0 : customFieldDefinition.node) &&
101
+ customFieldDefinition.node.definitionId &&
102
+ customFieldDefinition.node.title &&
103
+ customFieldDefinition.node.type) {
104
+ const column = columnHelper.accessor(data => {
105
+ var _a, _b, _c;
106
+ return (_c = (_b = (_a = data.customFields) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b.find(field => { var _a, _b; return ((_a = field === null || field === void 0 ? void 0 : field.node) === null || _a === void 0 ? void 0 : _a.definition.definitionId) === ((_b = customFieldDefinition.node) === null || _b === void 0 ? void 0 : _b.definitionId); })) === null || _c === void 0 ? void 0 : _c.node;
107
+ }, {
108
+ header: customFieldDefinition.node.title,
109
+ id: customFieldDefinition.node.definitionId,
110
+ enableSorting: false,
111
+ meta: {
112
+ hiddenByDefault: true,
113
+ },
114
+ cell: cell => {
115
+ const cellValue = cell.getValue();
116
+ return cellValue ? customFieldToCell(cellValue) : "";
117
+ },
118
+ });
119
+ result.push(column);
120
+ }
121
+ });
122
+ return result;
123
+ }, [customFieldDefinitions]);
124
+ };
125
+
126
+ /*
127
+ * ----------------------------
128
+ * | SETUP TRANSLATIONS START |
129
+ * ----------------------------
130
+ * This import and function call is needed to register translations for this library.
131
+ * Do not remove this if this library has translations.
132
+ */
133
+ setupLibraryTranslations();
134
+
135
+ export { useColumnDefinitionsFromCustomFieldDefinition };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@trackunit/react-table-helpers",
3
+ "version": "0.0.1-alpha-c761039087.0",
4
+ "repository": "https://github.com/Trackunit/manager",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "engines": {
7
+ "node": ">=18.x"
8
+ },
9
+ "dependencies": {
10
+ "@trackunit/i18n-library-translation": "0.0.73-alpha-c761039087.0",
11
+ "@trackunit/react-core-contexts-test": "0.1.100-alpha-c761039087.0",
12
+ "@trackunit/react-table": "0.0.6-alpha-c761039087.0",
13
+ "@trackunit/react-table-base-components": "0.0.1",
14
+ "react": "18.2.0"
15
+ },
16
+ "module": "./index.esm.js",
17
+ "main": "./index.cjs.js",
18
+ "peerDependencies": {}
19
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./useColumnDefinitionsFromCustomFieldDefinition/useColumnDefinitionsFromCustomFieldDefinition";
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { NamespaceTransProps, TransForLibs, TranslationResource } from "@trackunit/i18n-library-translation";
3
+ import defaultTranslations from "./locales/en/translation.json";
4
+ /** A type for all available translation keys in this library */
5
+ export type TranslationKeys = keyof typeof defaultTranslations;
6
+ /** The translation namespace for this library */
7
+ export declare const namespace = "react.table-helpers";
8
+ /**
9
+ * The TranslationResource for this Library.
10
+ * Holds lazy loaded imports for all languages supported by the library.
11
+ *
12
+ * This is used to register the translations for this library before initializing i18next.
13
+ */
14
+ export declare const translations: TranslationResource<TranslationKeys>;
15
+ /**
16
+ * Local useTranslation for this specific library
17
+ */
18
+ export declare const useTranslation: () => [TransForLibs<never>, import("i18next").i18n, boolean] & {
19
+ t: TransForLibs<never>;
20
+ i18n: import("i18next").i18n;
21
+ ready: boolean;
22
+ };
23
+ /**
24
+ * Type of the t function for the local useTranslation for this specific library
25
+ */
26
+ export type TranslationFunction = TransForLibs<TranslationKeys>;
27
+ /**
28
+ * Trans for this specific library.
29
+ */
30
+ export declare const Trans: (props: NamespaceTransProps<TranslationKeys>) => JSX.Element;
31
+ /**
32
+ * Registers the translations for this library
33
+ */
34
+ export declare const setupLibraryTranslations: () => void;
@@ -0,0 +1,5 @@
1
+ import { CustomFieldData } from "./types";
2
+ /**
3
+ * Takes a custom fields data object and returns a react node that can be used as a cell in a table.
4
+ */
5
+ export declare const customFieldToCell: (customField: CustomFieldData) => React.ReactNode;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The different types of custom fields that are available.
3
+ * Hardcoded to match the GraphQL API, to keep the lib independent of the API.
4
+ */
5
+ export type CustomFieldType = "BOOLEAN" | "DATE" | "DROPDOWN" | "EMAIL" | "NUMBER" | "PHONE_NUMBER" | "STRING" | "WEB_ADDRESS" | "JSON" | "MONETARY";
6
+ /**
7
+ * The type for the CustomFieldDefinition object from the GraphQL API.
8
+ * This is manually created to match the GraphQL API, to keep the lib independent of the API.
9
+ */
10
+ export interface CustomFieldDefinition {
11
+ definitionId: string;
12
+ title?: string | null;
13
+ key?: string | null;
14
+ type: CustomFieldType | null;
15
+ }
16
+ /**
17
+ * A representation of the CustomField data exprected to be in the table Data object when using custom fields.
18
+ */
19
+ export type CustomFieldData = {
20
+ valueId?: string | null;
21
+ booleanValue?: boolean | null;
22
+ type: "BOOLEAN";
23
+ definition: {
24
+ defaultBooleanValue?: boolean | null;
25
+ title?: string | null;
26
+ key?: string | null;
27
+ definitionId?: string | null;
28
+ };
29
+ } | {
30
+ valueId?: string | null;
31
+ dateValue?: string | null;
32
+ type: "DATE";
33
+ definition: {
34
+ defaultDateValue?: string | null;
35
+ title?: string | null;
36
+ key?: string | null;
37
+ definitionId?: string | null;
38
+ };
39
+ } | {
40
+ valueId?: string | null;
41
+ type: "DROPDOWN";
42
+ definition: {
43
+ defaultStringArrayValue?: string[] | null;
44
+ title?: string | null;
45
+ key?: string | null;
46
+ definitionId?: string | null;
47
+ };
48
+ stringArrayValue?: string[];
49
+ } | {
50
+ valueId?: string | null;
51
+ stringValue?: string | null;
52
+ type: "EMAIL";
53
+ definition: {
54
+ defaultStringValue?: string | null;
55
+ title?: string | null;
56
+ key?: string | null;
57
+ definitionId?: string | null;
58
+ };
59
+ } | {
60
+ valueId?: string | null;
61
+ jsonValue?: unknown | null;
62
+ type: "JSON";
63
+ definition: {
64
+ defaultJsonValue?: unknown | null;
65
+ title?: string | null;
66
+ key?: string | null;
67
+ definitionId?: string | null;
68
+ };
69
+ } | {
70
+ valueId?: string | null;
71
+ numberValue?: number | null;
72
+ type: "NUMBER";
73
+ definition: {
74
+ defaultNumberValue?: number | null;
75
+ title?: string | null;
76
+ key?: string | null;
77
+ definitionId?: string | null;
78
+ };
79
+ } | {
80
+ valueId?: string | null;
81
+ numberValue?: number | null;
82
+ type: "MONETARY";
83
+ definition: {
84
+ defaultNumberValue?: number | null;
85
+ title?: string | null;
86
+ key?: string | null;
87
+ definitionId?: string | null;
88
+ };
89
+ } | {
90
+ valueId?: string | null;
91
+ stringValue?: string | null;
92
+ type: "WEB_ADDRESS";
93
+ definition: {
94
+ defaultStringValue?: string | null;
95
+ title?: string | null;
96
+ key?: string | null;
97
+ definitionId?: string | null;
98
+ };
99
+ } | {
100
+ valueId?: string | null;
101
+ stringValue?: string | null;
102
+ type: "PHONE_NUMBER";
103
+ definition: {
104
+ defaultStringValue?: string | null;
105
+ title?: string | null;
106
+ key?: string | null;
107
+ definitionId?: string | null;
108
+ };
109
+ } | {
110
+ valueId?: string | null;
111
+ stringValue?: string | null;
112
+ type: "STRING";
113
+ definition: {
114
+ defaultStringValue?: string | null;
115
+ title?: string | null;
116
+ key?: string | null;
117
+ definitionId?: string | null;
118
+ };
119
+ };
120
+ /**
121
+ * This is the type for a data object that has custom fields.
122
+ * This is the type of the data that is returned from the GraphQL API when attaching custom fields to a query.
123
+ */
124
+ export interface DataWithCustomFields {
125
+ customFields?: {
126
+ edges?: ({
127
+ node?: CustomFieldData | null;
128
+ } | null)[] | null;
129
+ } | null;
130
+ }
131
+ /**
132
+ * This is the type of the data that is returned from the GraphQL API for the custom field definitions.
133
+ * This is what is used to generate the ColumnDefinitions for the table.
134
+ */
135
+ export type CustomFieldDefinitionEdgesContainer = {
136
+ edges?: ({
137
+ node?: CustomFieldDefinition | null;
138
+ } | null)[] | null;
139
+ } | null;
140
+ export type CustomFieldDefinitionArray = NonNullable<CustomFieldDefinitionEdgesContainer>["edges"];
@@ -0,0 +1,13 @@
1
+ import { ColumnDef } from "@trackunit/react-table";
2
+ import { CustomFieldData, CustomFieldDefinitionArray, DataWithCustomFields } from "./types";
3
+ export interface UseColumnDefinitionsFromCustomFieldDefinitionProps {
4
+ customFieldDefinitions?: CustomFieldDefinitionArray;
5
+ }
6
+ /**
7
+ * Generates an array of table column definitions based on custom field definitions.
8
+ *
9
+ * @template TDataType - The data type with custom fields.
10
+ * @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
11
+ * @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
12
+ */
13
+ export declare const useColumnDefinitionsFromCustomFieldDefinition: <TDataType extends DataWithCustomFields>({ customFieldDefinitions, }: UseColumnDefinitionsFromCustomFieldDefinitionProps) => ColumnDef<TDataType, CustomFieldData | undefined>[];
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };