@trackunit/react-table-helpers 1.3.51 → 1.3.52

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
@@ -55,47 +55,44 @@ 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
- const type = customField.type;
58
+ const type = customField.__typename;
59
59
  switch (type) {
60
- case "BOOLEAN": {
60
+ case "BooleanFieldValueAndDefinition": {
61
61
  const checked = customField.booleanValue ?? false;
62
62
  return jsxRuntime.jsx(reactTableBaseComponents.CheckboxCell, { checked: checked });
63
63
  }
64
- case "STRING":
64
+ case "StringFieldValueAndDefinition":
65
65
  return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: customField.stringValue?.toString() ?? "" });
66
- case "EMAIL":
67
- case "PHONE_NUMBER":
68
- case "WEB_ADDRESS": {
69
- const link = customField.stringValue ?? "";
70
- const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
71
- return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: link, type: linkType });
66
+ case "EmailFieldValueAndDefinition":
67
+ return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: customField.emailValue?.toString() ?? "", type: "EMAIL" });
68
+ case "PhoneNumberFieldValueAndDefinition":
69
+ return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: customField.phoneNumberValue?.toString() ?? "", type: "PHONE" });
70
+ case "WebAddressFieldValueAndDefinition": {
71
+ return jsxRuntime.jsx(reactTableBaseComponents.LinkCell, { link: customField.webAddressValue ?? "", type: "LINK" });
72
72
  }
73
- case "DATE": {
73
+ case "DateFieldValueAndDefinition": {
74
74
  const date = customField.dateValue;
75
75
  return date ? jsxRuntime.jsx(reactTableBaseComponents.PlainDateCell, { date: polyfill.Temporal.PlainDate.from(date), locale: language }) : null;
76
76
  }
77
- case "STRING_LIST":
78
- case "DROPDOWN": {
77
+ case "StringListFieldValueAndDefinition":
78
+ case "DropDownFieldValueAndDefinition": {
79
79
  const tags = customField.stringArrayValue ?? [];
80
80
  return jsxRuntime.jsx(reactTableBaseComponents.TagsCell, { tags: tags });
81
81
  }
82
- case "JSON":
82
+ case "JsonFieldValueAndDefinition":
83
83
  return jsxRuntime.jsx(reactTableBaseComponents.TextCell, { content: customField.jsonValue?.toString() ?? "" });
84
- case "NUMBER": {
84
+ case "NumberFieldValueAndDefinition": {
85
85
  const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
86
86
  const value = customField.numberValue ? customField.numberValue + "" : undefined;
87
87
  const updatedValue = irisAppRuntimeCore.getCustomFieldValueForDisplayInUI(value, unitType, unitPreference, language);
88
88
  return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { unit: unitTranslation(unitType), value: updatedValue });
89
89
  }
90
- case "MONETARY":
91
- return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: customField.numberValue?.toString() ?? "" });
90
+ case "MonetaryFieldValueAndDefinition":
91
+ return jsxRuntime.jsx(reactTableBaseComponents.NumberCell, { value: customField.monetaryValue?.toString() ?? "" });
92
92
  default:
93
- return assertNever(type);
93
+ throw new Error(`Unexpected value: ${type}`);
94
94
  }
95
95
  };
96
- function assertNever(value) {
97
- throw new Error(`Unexpected value: ${value}`);
98
- }
99
96
 
100
97
  /**
101
98
  * Generates an array of table column definitions based on custom field definitions.
@@ -113,13 +110,13 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
113
110
  if (customFieldDefinition?.node &&
114
111
  customFieldDefinition.node.id &&
115
112
  customFieldDefinition.node.title &&
116
- customFieldDefinition.node.type) {
113
+ customFieldDefinition.node.__typename) {
117
114
  const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
118
115
  return field?.node?.definition.id === customFieldDefinition.node?.id;
119
116
  })?.node, {
120
117
  header: customFieldDefinition.node.title,
121
118
  id: customFieldDefinition.node.id,
122
- enableSorting: customFieldDefinition.node.type !== "DROPDOWN" && customFieldDefinition.node.type !== "STRING_LIST",
119
+ enableSorting: customFieldDefinition.node.__typename !== "DropDownFieldDefinition" && customFieldDefinition.node.__typename !== "StringListFieldDefinition",
123
120
  meta: {
124
121
  hiddenByDefault: true,
125
122
  isCustomField: true,
package/index.esm.js CHANGED
@@ -53,47 +53,44 @@ 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
- const type = customField.type;
56
+ const type = customField.__typename;
57
57
  switch (type) {
58
- case "BOOLEAN": {
58
+ case "BooleanFieldValueAndDefinition": {
59
59
  const checked = customField.booleanValue ?? false;
60
60
  return jsx(CheckboxCell, { checked: checked });
61
61
  }
62
- case "STRING":
62
+ case "StringFieldValueAndDefinition":
63
63
  return jsx(TextCell, { content: customField.stringValue?.toString() ?? "" });
64
- case "EMAIL":
65
- case "PHONE_NUMBER":
66
- case "WEB_ADDRESS": {
67
- const link = customField.stringValue ?? "";
68
- const linkType = customField.type === "WEB_ADDRESS" ? "LINK" : customField.type === "PHONE_NUMBER" ? "PHONE" : "EMAIL";
69
- return jsx(LinkCell, { link: link, type: linkType });
64
+ case "EmailFieldValueAndDefinition":
65
+ return jsx(LinkCell, { link: customField.emailValue?.toString() ?? "", type: "EMAIL" });
66
+ case "PhoneNumberFieldValueAndDefinition":
67
+ return jsx(LinkCell, { link: customField.phoneNumberValue?.toString() ?? "", type: "PHONE" });
68
+ case "WebAddressFieldValueAndDefinition": {
69
+ return jsx(LinkCell, { link: customField.webAddressValue ?? "", type: "LINK" });
70
70
  }
71
- case "DATE": {
71
+ case "DateFieldValueAndDefinition": {
72
72
  const date = customField.dateValue;
73
73
  return date ? jsx(PlainDateCell, { date: Temporal.PlainDate.from(date), locale: language }) : null;
74
74
  }
75
- case "STRING_LIST":
76
- case "DROPDOWN": {
75
+ case "StringListFieldValueAndDefinition":
76
+ case "DropDownFieldValueAndDefinition": {
77
77
  const tags = customField.stringArrayValue ?? [];
78
78
  return jsx(TagsCell, { tags: tags });
79
79
  }
80
- case "JSON":
80
+ case "JsonFieldValueAndDefinition":
81
81
  return jsx(TextCell, { content: customField.jsonValue?.toString() ?? "" });
82
- case "NUMBER": {
82
+ case "NumberFieldValueAndDefinition": {
83
83
  const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
84
84
  const value = customField.numberValue ? customField.numberValue + "" : undefined;
85
85
  const updatedValue = getCustomFieldValueForDisplayInUI(value, unitType, unitPreference, language);
86
86
  return jsx(NumberCell, { unit: unitTranslation(unitType), value: updatedValue });
87
87
  }
88
- case "MONETARY":
89
- return jsx(NumberCell, { value: customField.numberValue?.toString() ?? "" });
88
+ case "MonetaryFieldValueAndDefinition":
89
+ return jsx(NumberCell, { value: customField.monetaryValue?.toString() ?? "" });
90
90
  default:
91
- return assertNever(type);
91
+ throw new Error(`Unexpected value: ${type}`);
92
92
  }
93
93
  };
94
- function assertNever(value) {
95
- throw new Error(`Unexpected value: ${value}`);
96
- }
97
94
 
98
95
  /**
99
96
  * Generates an array of table column definitions based on custom field definitions.
@@ -111,13 +108,13 @@ const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions,
111
108
  if (customFieldDefinition?.node &&
112
109
  customFieldDefinition.node.id &&
113
110
  customFieldDefinition.node.title &&
114
- customFieldDefinition.node.type) {
111
+ customFieldDefinition.node.__typename) {
115
112
  const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
116
113
  return field?.node?.definition.id === customFieldDefinition.node?.id;
117
114
  })?.node, {
118
115
  header: customFieldDefinition.node.title,
119
116
  id: customFieldDefinition.node.id,
120
- enableSorting: customFieldDefinition.node.type !== "DROPDOWN" && customFieldDefinition.node.type !== "STRING_LIST",
117
+ enableSorting: customFieldDefinition.node.__typename !== "DropDownFieldDefinition" && customFieldDefinition.node.__typename !== "StringListFieldDefinition",
121
118
  meta: {
122
119
  hiddenByDefault: true,
123
120
  isCustomField: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table-helpers",
3
- "version": "1.3.51",
3
+ "version": "1.3.52",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,11 +10,11 @@
10
10
  "react": "19.0.0",
11
11
  "@js-temporal/polyfill": "^0.4.4",
12
12
  "@trackunit/i18n-library-translation": "1.3.38",
13
- "@trackunit/custom-field-components": "1.3.48",
14
- "@trackunit/iris-app-runtime-core": "1.4.37",
13
+ "@trackunit/custom-field-components": "1.3.49",
14
+ "@trackunit/iris-app-runtime-core": "1.4.38",
15
15
  "@trackunit/react-core-contexts-api": "1.4.37",
16
16
  "@trackunit/react-table-base-components": "1.3.46",
17
- "@trackunit/iris-app-runtime-core-api": "1.3.37",
17
+ "@trackunit/iris-app-runtime-core-api": "1.3.38",
18
18
  "@trackunit/react-table": "1.3.49"
19
19
  },
20
20
  "module": "./index.esm.js",
@@ -12,7 +12,7 @@ export interface CustomFieldDefinition {
12
12
  id: string;
13
13
  title?: string | null;
14
14
  key?: string | null;
15
- type: CustomFieldType | null;
15
+ __typename?: "BooleanFieldDefinition" | "DateFieldDefinition" | "DropDownFieldDefinition" | "EmailFieldDefinition" | "JsonFieldDefinition" | "MonetaryFieldDefinition" | "NumberFieldDefinition" | "PhoneNumberFieldDefinition" | "StringFieldDefinition" | "StringListFieldDefinition" | "WebAddressFieldDefinition" | null;
16
16
  }
17
17
  /**
18
18
  * A representation of the CustomField data exprected to be in the table Data object when using custom fields.
@@ -20,8 +20,9 @@ export interface CustomFieldDefinition {
20
20
  export type CustomFieldData = {
21
21
  valueId?: string | null;
22
22
  booleanValue?: boolean | null;
23
- type: "BOOLEAN";
23
+ __typename?: "BooleanFieldValueAndDefinition";
24
24
  definition: {
25
+ __typename?: "BooleanFieldDefinition";
25
26
  title?: string | null;
26
27
  key?: string | null;
27
28
  id?: string | null;
@@ -29,16 +30,18 @@ export type CustomFieldData = {
29
30
  } | {
30
31
  valueId?: string | null;
31
32
  dateValue?: string | null;
32
- type: "DATE";
33
+ __typename?: "DateFieldValueAndDefinition";
33
34
  definition: {
35
+ __typename?: "DateFieldDefinition";
34
36
  title?: string | null;
35
37
  key?: string | null;
36
38
  id?: string | null;
37
39
  };
38
40
  } | {
39
41
  valueId?: string | null;
40
- type: "DROPDOWN";
42
+ __typename?: "DropDownFieldValueAndDefinition";
41
43
  definition: {
44
+ __typename?: "DropDownFieldDefinition";
42
45
  title?: string | null;
43
46
  key?: string | null;
44
47
  id?: string | null;
@@ -46,8 +49,9 @@ export type CustomFieldData = {
46
49
  stringArrayValue?: string[] | null;
47
50
  } | {
48
51
  valueId?: string | null;
49
- type: "STRING_LIST";
52
+ __typename?: "StringListFieldValueAndDefinition";
50
53
  definition: {
54
+ __typename?: "StringListFieldDefinition";
51
55
  title?: string | null;
52
56
  key?: string | null;
53
57
  id?: string | null;
@@ -55,9 +59,10 @@ export type CustomFieldData = {
55
59
  stringArrayValue?: string[] | null;
56
60
  } | {
57
61
  valueId?: string | null;
58
- stringValue?: string | null;
59
- type: "EMAIL";
62
+ emailValue?: string | null;
63
+ __typename?: "EmailFieldValueAndDefinition";
60
64
  definition: {
65
+ __typename?: "EmailFieldDefinition";
61
66
  title?: string | null;
62
67
  key?: string | null;
63
68
  id?: string | null;
@@ -65,8 +70,9 @@ export type CustomFieldData = {
65
70
  } | {
66
71
  valueId?: string | null;
67
72
  jsonValue?: unknown | null;
68
- type: "JSON";
73
+ __typename?: "JsonFieldValueAndDefinition";
69
74
  definition: {
75
+ __typename?: "JsonFieldDefinition";
70
76
  title?: string | null;
71
77
  key?: string | null;
72
78
  id?: string | null;
@@ -74,8 +80,9 @@ export type CustomFieldData = {
74
80
  } | {
75
81
  valueId?: string | null;
76
82
  numberValue?: number | null;
77
- type: "NUMBER";
83
+ __typename?: "NumberFieldValueAndDefinition";
78
84
  definition: {
85
+ __typename?: "NumberFieldDefinition";
79
86
  title?: string | null;
80
87
  key?: string | null;
81
88
  id?: string | null;
@@ -84,27 +91,30 @@ export type CustomFieldData = {
84
91
  };
85
92
  } | {
86
93
  valueId?: string | null;
87
- numberValue?: number | null;
88
- type: "MONETARY";
94
+ monetaryValue?: number | null;
95
+ __typename?: "MonetaryFieldValueAndDefinition";
89
96
  definition: {
97
+ __typename?: "MonetaryFieldDefinition";
90
98
  title?: string | null;
91
99
  key?: string | null;
92
100
  id?: string | null;
93
101
  };
94
102
  } | {
95
103
  valueId?: string | null;
96
- stringValue?: string | null;
97
- type: "WEB_ADDRESS";
104
+ webAddressValue?: string | null;
105
+ __typename?: "WebAddressFieldValueAndDefinition";
98
106
  definition: {
107
+ __typename?: "WebAddressFieldDefinition";
99
108
  title?: string | null;
100
109
  key?: string | null;
101
110
  id?: string | null;
102
111
  };
103
112
  } | {
104
113
  valueId?: string | null;
105
- stringValue?: string | null;
106
- type: "PHONE_NUMBER";
114
+ phoneNumberValue?: string | null;
115
+ __typename?: "PhoneNumberFieldValueAndDefinition";
107
116
  definition: {
117
+ __typename?: "PhoneNumberFieldDefinition";
108
118
  title?: string | null;
109
119
  key?: string | null;
110
120
  id?: string | null;
@@ -112,8 +122,9 @@ export type CustomFieldData = {
112
122
  } | {
113
123
  valueId?: string | null;
114
124
  stringValue?: string | null;
115
- type: "STRING";
125
+ __typename?: "StringFieldValueAndDefinition";
116
126
  definition: {
127
+ __typename?: "StringFieldDefinition";
117
128
  title?: string | null;
118
129
  key?: string | null;
119
130
  id?: string | null;