@trackunit/custom-field-table-helpers 0.0.0-stage → 1.0.1
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/README.md +11 -2
- package/index.cjs.js +394 -0
- package/index.d.ts +1 -0
- package/index.esm.js +390 -0
- package/migrations/entry.js +3 -0
- package/migrations.json +3 -0
- package/package.json +31 -3
- package/src/generated/graphql-api/fragment-masking.d.ts +19 -0
- package/src/generated/graphql-api/gql.d.ts +35 -0
- package/src/generated/graphql-api/graphql.d.ts +323 -0
- package/src/generated/graphql-api/index.d.ts +2 -0
- package/src/index.d.ts +4 -0
- package/src/useColumnDefinitionsFromCustomFieldDefinition/customFieldToCell.d.ts +8 -0
- package/src/useColumnDefinitionsFromCustomFieldDefinition/customFieldToExportString.d.ts +8 -0
- package/src/useColumnDefinitionsFromCustomFieldDefinition/types.d.ts +165 -0
- package/src/useColumnDefinitionsFromCustomFieldDefinition/useColumnDefinitionsFromCustomFieldDefinition.d.ts +18 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core";
|
|
2
|
+
import type { PublicIrisAppManifest } from "@trackunit/iris-app-api";
|
|
3
|
+
export type Maybe<T> = T | null;
|
|
4
|
+
export type InputMaybe<T> = Maybe<T> | undefined;
|
|
5
|
+
export type Exact<T extends {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}> = {
|
|
8
|
+
[K in keyof T]: T[K];
|
|
9
|
+
};
|
|
10
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
11
|
+
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
12
|
+
};
|
|
13
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
14
|
+
[SubKey in K]: Maybe<T[SubKey]>;
|
|
15
|
+
};
|
|
16
|
+
export type MakeEmpty<T extends {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}, K extends keyof T> = {
|
|
19
|
+
[_ in K]?: never;
|
|
20
|
+
};
|
|
21
|
+
export type Incremental<T> = T | {
|
|
22
|
+
[P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never;
|
|
23
|
+
};
|
|
24
|
+
export type DateTimeISOString = string;
|
|
25
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
26
|
+
export type Scalars = {
|
|
27
|
+
ID: {
|
|
28
|
+
input: string;
|
|
29
|
+
output: string;
|
|
30
|
+
};
|
|
31
|
+
String: {
|
|
32
|
+
input: string;
|
|
33
|
+
output: string;
|
|
34
|
+
};
|
|
35
|
+
Boolean: {
|
|
36
|
+
input: boolean;
|
|
37
|
+
output: boolean;
|
|
38
|
+
};
|
|
39
|
+
Int: {
|
|
40
|
+
input: number;
|
|
41
|
+
output: number;
|
|
42
|
+
};
|
|
43
|
+
Float: {
|
|
44
|
+
input: number;
|
|
45
|
+
output: number;
|
|
46
|
+
};
|
|
47
|
+
/** The ISO 4217 currency code of the monetary field definition. */
|
|
48
|
+
Currency: {
|
|
49
|
+
input: string;
|
|
50
|
+
output: string;
|
|
51
|
+
};
|
|
52
|
+
/** Cursor scalar. */
|
|
53
|
+
Cursor: {
|
|
54
|
+
input: string;
|
|
55
|
+
output: string;
|
|
56
|
+
};
|
|
57
|
+
/** Date scalar */
|
|
58
|
+
Date: {
|
|
59
|
+
input: DateTimeISOString;
|
|
60
|
+
output: DateTimeISOString;
|
|
61
|
+
};
|
|
62
|
+
/** DateTime represents a “date-time” as specified in section 5.6 of RFC 3339 */
|
|
63
|
+
DateTime: {
|
|
64
|
+
input: DateTimeISOString;
|
|
65
|
+
output: DateTimeISOString;
|
|
66
|
+
};
|
|
67
|
+
/** Duration represents an ISO 8601 duration */
|
|
68
|
+
Duration: {
|
|
69
|
+
input: any;
|
|
70
|
+
output: any;
|
|
71
|
+
};
|
|
72
|
+
/** Valid email address according to https://owasp.org/www-community/OWASP_Validation_Regex_Repository */
|
|
73
|
+
EmailAddress: {
|
|
74
|
+
input: string;
|
|
75
|
+
output: string;
|
|
76
|
+
};
|
|
77
|
+
/** A (possiblely multidimensional) set of coordinates following x, y, z order. */
|
|
78
|
+
GeoJSONCoordinates: {
|
|
79
|
+
input: [number, number] | [number, number][] | [number, number][][];
|
|
80
|
+
output: [number, number] | [number, number][] | [number, number][][];
|
|
81
|
+
};
|
|
82
|
+
/** Raw JSON object structure, not serialized to string */
|
|
83
|
+
JSON: {
|
|
84
|
+
input: any;
|
|
85
|
+
output: any;
|
|
86
|
+
};
|
|
87
|
+
/** The `JSONObject` scalar type represents JSON values as a string */
|
|
88
|
+
JSONObject: {
|
|
89
|
+
input: any;
|
|
90
|
+
output: any;
|
|
91
|
+
};
|
|
92
|
+
/** 24-hour clock time string in the format hh:mm:ss.sss or hh:mm:ss if partial seconds is zero */
|
|
93
|
+
LocalTime: {
|
|
94
|
+
input: any;
|
|
95
|
+
output: any;
|
|
96
|
+
};
|
|
97
|
+
/** Javascript `Long`. Type represents a 64 bit integer. */
|
|
98
|
+
Long: {
|
|
99
|
+
input: any;
|
|
100
|
+
output: any;
|
|
101
|
+
};
|
|
102
|
+
/** Phone number in E.164 format */
|
|
103
|
+
PhoneNumber: {
|
|
104
|
+
input: string;
|
|
105
|
+
output: string;
|
|
106
|
+
};
|
|
107
|
+
/** The `PublicIrisAppManifest` scalar type represents an Iris App Manifest as JSON */
|
|
108
|
+
PublicIrisAppManifest: {
|
|
109
|
+
input: PublicIrisAppManifest;
|
|
110
|
+
output: PublicIrisAppManifest;
|
|
111
|
+
};
|
|
112
|
+
/** Uniform resource locator */
|
|
113
|
+
Url: {
|
|
114
|
+
input: string;
|
|
115
|
+
output: string;
|
|
116
|
+
};
|
|
117
|
+
/** YearMonth scalar */
|
|
118
|
+
YearMonth: {
|
|
119
|
+
input: any;
|
|
120
|
+
output: any;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
export declare const unitOfMeasurement: {
|
|
124
|
+
readonly ACRE: "ACRE";
|
|
125
|
+
readonly AMPERE: "AMPERE";
|
|
126
|
+
readonly AMPERE_HOUR: "AMPERE_HOUR";
|
|
127
|
+
readonly ARE: "ARE";
|
|
128
|
+
readonly BAR: "BAR";
|
|
129
|
+
readonly CELSIUS: "CELSIUS";
|
|
130
|
+
readonly CENTIMETRE: "CENTIMETRE";
|
|
131
|
+
readonly CUBIC_FOOT: "CUBIC_FOOT";
|
|
132
|
+
readonly CUBIC_METRE: "CUBIC_METRE";
|
|
133
|
+
readonly DAY: "DAY";
|
|
134
|
+
readonly DEGREE_ANGLE: "DEGREE_ANGLE";
|
|
135
|
+
readonly FAHRENHEIT: "FAHRENHEIT";
|
|
136
|
+
readonly FOOT: "FOOT";
|
|
137
|
+
readonly GALLONS_PER_HOUR: "GALLONS_PER_HOUR";
|
|
138
|
+
readonly GALLON_LIQUID: "GALLON_LIQUID";
|
|
139
|
+
readonly GRAM: "GRAM";
|
|
140
|
+
readonly G_FORCE: "G_FORCE";
|
|
141
|
+
readonly HECTARE: "HECTARE";
|
|
142
|
+
readonly HERTZ: "HERTZ";
|
|
143
|
+
readonly HOUR: "HOUR";
|
|
144
|
+
readonly INCH: "INCH";
|
|
145
|
+
readonly INCHES_OF_WATER: "INCHES_OF_WATER";
|
|
146
|
+
readonly KILOGRAM: "KILOGRAM";
|
|
147
|
+
readonly KILOGRAM_PER_HOUR: "KILOGRAM_PER_HOUR";
|
|
148
|
+
readonly KILOGRAM_PER_SECOND: "KILOGRAM_PER_SECOND";
|
|
149
|
+
readonly KILOMETRE: "KILOMETRE";
|
|
150
|
+
readonly KILOMETRE_PER_HOUR: "KILOMETRE_PER_HOUR";
|
|
151
|
+
readonly KILOPASCAL: "KILOPASCAL";
|
|
152
|
+
readonly KILOWATT: "KILOWATT";
|
|
153
|
+
readonly KILOWATT_HOUR: "KILOWATT_HOUR";
|
|
154
|
+
readonly LITRE: "LITRE";
|
|
155
|
+
readonly LITRES_PER_HOUR: "LITRES_PER_HOUR";
|
|
156
|
+
readonly METRE: "METRE";
|
|
157
|
+
readonly METRE_PER_SECOND: "METRE_PER_SECOND";
|
|
158
|
+
readonly METRE_PER_SECOND_SQUARED: "METRE_PER_SECOND_SQUARED";
|
|
159
|
+
readonly METRIC_TON: "METRIC_TON";
|
|
160
|
+
readonly MILE: "MILE";
|
|
161
|
+
readonly MILE_PER_HOUR: "MILE_PER_HOUR";
|
|
162
|
+
readonly MILLIMETRE: "MILLIMETRE";
|
|
163
|
+
readonly MILLISECOND: "MILLISECOND";
|
|
164
|
+
readonly MINUTE: "MINUTE";
|
|
165
|
+
readonly MONTH: "MONTH";
|
|
166
|
+
readonly NEWTON: "NEWTON";
|
|
167
|
+
readonly OUNCE: "OUNCE";
|
|
168
|
+
readonly PASCAL: "PASCAL";
|
|
169
|
+
readonly PERCENT: "PERCENT";
|
|
170
|
+
readonly POUND: "POUND";
|
|
171
|
+
readonly POUND_PER_HOUR: "POUND_PER_HOUR";
|
|
172
|
+
readonly POUND_PER_SECOND: "POUND_PER_SECOND";
|
|
173
|
+
readonly POUND_PER_SQUARE_INCH: "POUND_PER_SQUARE_INCH";
|
|
174
|
+
readonly REVOLUTIONS_PER_MINUTE: "REVOLUTIONS_PER_MINUTE";
|
|
175
|
+
readonly SECOND: "SECOND";
|
|
176
|
+
readonly SQUARE_FOOT: "SQUARE_FOOT";
|
|
177
|
+
readonly SQUARE_KILOMETRE: "SQUARE_KILOMETRE";
|
|
178
|
+
readonly SQUARE_METRE: "SQUARE_METRE";
|
|
179
|
+
readonly US_TON: "US_TON";
|
|
180
|
+
readonly VOLT: "VOLT";
|
|
181
|
+
readonly VOLT_AMPERE: "VOLT_AMPERE";
|
|
182
|
+
readonly WATT: "WATT";
|
|
183
|
+
readonly WEEK: "WEEK";
|
|
184
|
+
readonly YARD: "YARD";
|
|
185
|
+
readonly YEAR: "YEAR";
|
|
186
|
+
};
|
|
187
|
+
export type UnitOfMeasurement = (typeof unitOfMeasurement)[keyof typeof unitOfMeasurement];
|
|
188
|
+
export type AssetCustomFieldsFragment = {
|
|
189
|
+
__typename?: "Asset";
|
|
190
|
+
customFields: {
|
|
191
|
+
__typename?: "CustomFieldValueAndDefinitionConnection";
|
|
192
|
+
edges: Array<{
|
|
193
|
+
__typename?: "CustomFieldValueAndDefinitionEdge";
|
|
194
|
+
node: {
|
|
195
|
+
__typename: "BooleanFieldValueAndDefinition";
|
|
196
|
+
booleanValue: boolean | null;
|
|
197
|
+
valueId: string | null;
|
|
198
|
+
definition: {
|
|
199
|
+
__typename?: "BooleanFieldDefinition";
|
|
200
|
+
id: string;
|
|
201
|
+
title: string | null;
|
|
202
|
+
key: string | null;
|
|
203
|
+
};
|
|
204
|
+
} | {
|
|
205
|
+
__typename: "DateFieldValueAndDefinition";
|
|
206
|
+
dateValue: DateTimeISOString | null;
|
|
207
|
+
valueId: string | null;
|
|
208
|
+
definition: {
|
|
209
|
+
__typename?: "DateFieldDefinition";
|
|
210
|
+
id: string;
|
|
211
|
+
title: string | null;
|
|
212
|
+
key: string | null;
|
|
213
|
+
};
|
|
214
|
+
} | {
|
|
215
|
+
__typename: "DropDownFieldValueAndDefinition";
|
|
216
|
+
stringArrayValue: Array<string> | null;
|
|
217
|
+
valueId: string | null;
|
|
218
|
+
definition: {
|
|
219
|
+
__typename?: "DropDownFieldDefinition";
|
|
220
|
+
id: string;
|
|
221
|
+
title: string | null;
|
|
222
|
+
key: string | null;
|
|
223
|
+
};
|
|
224
|
+
} | {
|
|
225
|
+
__typename: "EmailFieldValueAndDefinition";
|
|
226
|
+
emailValue: string | null;
|
|
227
|
+
valueId: string | null;
|
|
228
|
+
definition: {
|
|
229
|
+
__typename?: "EmailFieldDefinition";
|
|
230
|
+
id: string;
|
|
231
|
+
title: string | null;
|
|
232
|
+
key: string | null;
|
|
233
|
+
};
|
|
234
|
+
} | {
|
|
235
|
+
__typename: "FileFieldValueAndDefinition";
|
|
236
|
+
fileName: string | null;
|
|
237
|
+
downloadLink: string | null;
|
|
238
|
+
valueId: string | null;
|
|
239
|
+
definition: {
|
|
240
|
+
__typename?: "FileFieldDefinition";
|
|
241
|
+
id: string;
|
|
242
|
+
title: string | null;
|
|
243
|
+
key: string | null;
|
|
244
|
+
};
|
|
245
|
+
} | {
|
|
246
|
+
__typename: "JsonFieldValueAndDefinition";
|
|
247
|
+
jsonValue: any | null;
|
|
248
|
+
valueId: string | null;
|
|
249
|
+
definition: {
|
|
250
|
+
__typename?: "JsonFieldDefinition";
|
|
251
|
+
id: string;
|
|
252
|
+
title: string | null;
|
|
253
|
+
key: string | null;
|
|
254
|
+
};
|
|
255
|
+
} | {
|
|
256
|
+
__typename: "MonetaryFieldValueAndDefinition";
|
|
257
|
+
monetaryValue: number | null;
|
|
258
|
+
valueId: string | null;
|
|
259
|
+
definition: {
|
|
260
|
+
__typename?: "MonetaryFieldDefinition";
|
|
261
|
+
id: string;
|
|
262
|
+
title: string | null;
|
|
263
|
+
key: string | null;
|
|
264
|
+
};
|
|
265
|
+
} | {
|
|
266
|
+
__typename: "NumberFieldValueAndDefinition";
|
|
267
|
+
numberValue: number | null;
|
|
268
|
+
valueId: string | null;
|
|
269
|
+
definition: {
|
|
270
|
+
__typename?: "NumberFieldDefinition";
|
|
271
|
+
unitSi: UnitOfMeasurement | null;
|
|
272
|
+
unitUs: UnitOfMeasurement | null;
|
|
273
|
+
id: string;
|
|
274
|
+
title: string | null;
|
|
275
|
+
key: string | null;
|
|
276
|
+
};
|
|
277
|
+
} | {
|
|
278
|
+
__typename: "PhoneNumberFieldValueAndDefinition";
|
|
279
|
+
phoneNumberValue: string | null;
|
|
280
|
+
valueId: string | null;
|
|
281
|
+
definition: {
|
|
282
|
+
__typename?: "PhoneNumberFieldDefinition";
|
|
283
|
+
id: string;
|
|
284
|
+
title: string | null;
|
|
285
|
+
key: string | null;
|
|
286
|
+
};
|
|
287
|
+
} | {
|
|
288
|
+
__typename: "StringFieldValueAndDefinition";
|
|
289
|
+
stringValue: string | null;
|
|
290
|
+
valueId: string | null;
|
|
291
|
+
definition: {
|
|
292
|
+
__typename?: "StringFieldDefinition";
|
|
293
|
+
id: string;
|
|
294
|
+
title: string | null;
|
|
295
|
+
key: string | null;
|
|
296
|
+
};
|
|
297
|
+
} | {
|
|
298
|
+
__typename: "StringListFieldValueAndDefinition";
|
|
299
|
+
stringArrayValue: Array<string> | null;
|
|
300
|
+
valueId: string | null;
|
|
301
|
+
definition: {
|
|
302
|
+
__typename?: "StringListFieldDefinition";
|
|
303
|
+
id: string;
|
|
304
|
+
title: string | null;
|
|
305
|
+
key: string | null;
|
|
306
|
+
};
|
|
307
|
+
} | {
|
|
308
|
+
__typename: "WebAddressFieldValueAndDefinition";
|
|
309
|
+
webAddressValue: string | null;
|
|
310
|
+
valueId: string | null;
|
|
311
|
+
definition: {
|
|
312
|
+
__typename?: "WebAddressFieldDefinition";
|
|
313
|
+
id: string;
|
|
314
|
+
title: string | null;
|
|
315
|
+
key: string | null;
|
|
316
|
+
};
|
|
317
|
+
} | null;
|
|
318
|
+
} | null> | null;
|
|
319
|
+
} | null;
|
|
320
|
+
} & {
|
|
321
|
+
" $fragmentName"?: "AssetCustomFieldsFragment";
|
|
322
|
+
};
|
|
323
|
+
export declare const AssetCustomFieldsFragmentDoc: DocumentNode<AssetCustomFieldsFragment, unknown>;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./useColumnDefinitionsFromCustomFieldDefinition/customFieldToCell";
|
|
2
|
+
export * from "./useColumnDefinitionsFromCustomFieldDefinition/customFieldToExportString";
|
|
3
|
+
export type { CustomFieldData, DataWithCustomFields } from "./useColumnDefinitionsFromCustomFieldDefinition/types";
|
|
4
|
+
export * from "./useColumnDefinitionsFromCustomFieldDefinition/useColumnDefinitionsFromCustomFieldDefinition";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UnitType } from "@trackunit/custom-field-components";
|
|
2
|
+
import { SystemOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { CustomFieldData } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
7
|
+
*/
|
|
8
|
+
export declare const customFieldToCell: (customField: CustomFieldData, unitTranslation: (unit: UnitType) => string | null, unitPreference?: SystemOfMeasurementType | null, language?: string) => ReactNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UnitType } from "@trackunit/custom-field-components";
|
|
2
|
+
import { SystemOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { CustomFieldData } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
7
|
+
*/
|
|
8
|
+
export declare const customFieldToExportString: (customField: CustomFieldData, unitTranslation: (unit: UnitType) => string | null, unitPreference?: SystemOfMeasurementType | null, language?: string) => ReactNode;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { UnitOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
2
|
+
/**
|
|
3
|
+
* The different types of custom fields that are available.
|
|
4
|
+
* Hardcoded to match the GraphQL API, to keep the lib independent of the API.
|
|
5
|
+
*/
|
|
6
|
+
export type CustomFieldType = "BOOLEAN" | "DATE" | "DROPDOWN" | "STRING_LIST" | "EMAIL" | "FILE" | "NUMBER" | "PHONE_NUMBER" | "STRING" | "WEB_ADDRESS" | "JSON" | "MONETARY";
|
|
7
|
+
/**
|
|
8
|
+
* The type for the CustomFieldDefinition object from the GraphQL API.
|
|
9
|
+
* This is manually created to match the GraphQL API, to keep the lib independent of the API.
|
|
10
|
+
*/
|
|
11
|
+
export interface CustomFieldDefinition {
|
|
12
|
+
id: string;
|
|
13
|
+
title?: string | null;
|
|
14
|
+
key?: string | null;
|
|
15
|
+
__typename?: "BooleanFieldDefinition" | "DateFieldDefinition" | "DropDownFieldDefinition" | "EmailFieldDefinition" | "FileFieldDefinition" | "JsonFieldDefinition" | "MonetaryFieldDefinition" | "NumberFieldDefinition" | "PhoneNumberFieldDefinition" | "StringFieldDefinition" | "StringListFieldDefinition" | "WebAddressFieldDefinition" | null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A representation of the CustomField data exprected to be in the table Data object when using custom fields.
|
|
19
|
+
*/
|
|
20
|
+
export type CustomFieldData = {
|
|
21
|
+
valueId?: string | null;
|
|
22
|
+
booleanValue?: boolean | null;
|
|
23
|
+
__typename?: "BooleanFieldValueAndDefinition";
|
|
24
|
+
definition: {
|
|
25
|
+
__typename?: "BooleanFieldDefinition";
|
|
26
|
+
title?: string | null;
|
|
27
|
+
key?: string | null;
|
|
28
|
+
id?: string | null;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
valueId?: string | null;
|
|
32
|
+
dateValue?: string | null;
|
|
33
|
+
__typename?: "DateFieldValueAndDefinition";
|
|
34
|
+
definition: {
|
|
35
|
+
__typename?: "DateFieldDefinition";
|
|
36
|
+
title?: string | null;
|
|
37
|
+
key?: string | null;
|
|
38
|
+
id?: string | null;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
valueId?: string | null;
|
|
42
|
+
__typename?: "DropDownFieldValueAndDefinition";
|
|
43
|
+
definition: {
|
|
44
|
+
__typename?: "DropDownFieldDefinition";
|
|
45
|
+
title?: string | null;
|
|
46
|
+
key?: string | null;
|
|
47
|
+
id?: string | null;
|
|
48
|
+
};
|
|
49
|
+
stringArrayValue?: Array<string> | null;
|
|
50
|
+
} | {
|
|
51
|
+
valueId?: string | null;
|
|
52
|
+
__typename?: "StringListFieldValueAndDefinition";
|
|
53
|
+
definition: {
|
|
54
|
+
__typename?: "StringListFieldDefinition";
|
|
55
|
+
title?: string | null;
|
|
56
|
+
key?: string | null;
|
|
57
|
+
id?: string | null;
|
|
58
|
+
};
|
|
59
|
+
stringArrayValue?: Array<string> | null;
|
|
60
|
+
} | {
|
|
61
|
+
valueId?: string | null;
|
|
62
|
+
emailValue?: string | null;
|
|
63
|
+
__typename?: "EmailFieldValueAndDefinition";
|
|
64
|
+
definition: {
|
|
65
|
+
__typename?: "EmailFieldDefinition";
|
|
66
|
+
title?: string | null;
|
|
67
|
+
key?: string | null;
|
|
68
|
+
id?: string | null;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
valueId?: string | null;
|
|
72
|
+
jsonValue?: unknown | null;
|
|
73
|
+
__typename?: "JsonFieldValueAndDefinition";
|
|
74
|
+
definition: {
|
|
75
|
+
__typename?: "JsonFieldDefinition";
|
|
76
|
+
title?: string | null;
|
|
77
|
+
key?: string | null;
|
|
78
|
+
id?: string | null;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
valueId?: string | null;
|
|
82
|
+
numberValue?: number | null;
|
|
83
|
+
__typename?: "NumberFieldValueAndDefinition";
|
|
84
|
+
definition: {
|
|
85
|
+
__typename?: "NumberFieldDefinition";
|
|
86
|
+
title?: string | null;
|
|
87
|
+
key?: string | null;
|
|
88
|
+
id?: string | null;
|
|
89
|
+
unitSi?: UnitOfMeasurementType | null;
|
|
90
|
+
unitUs?: UnitOfMeasurementType | null;
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
valueId?: string | null;
|
|
94
|
+
monetaryValue?: number | null;
|
|
95
|
+
__typename?: "MonetaryFieldValueAndDefinition";
|
|
96
|
+
definition: {
|
|
97
|
+
__typename?: "MonetaryFieldDefinition";
|
|
98
|
+
title?: string | null;
|
|
99
|
+
key?: string | null;
|
|
100
|
+
id?: string | null;
|
|
101
|
+
};
|
|
102
|
+
} | {
|
|
103
|
+
valueId?: string | null;
|
|
104
|
+
webAddressValue?: string | null;
|
|
105
|
+
__typename?: "WebAddressFieldValueAndDefinition";
|
|
106
|
+
definition: {
|
|
107
|
+
__typename?: "WebAddressFieldDefinition";
|
|
108
|
+
title?: string | null;
|
|
109
|
+
key?: string | null;
|
|
110
|
+
id?: string | null;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
valueId?: string | null;
|
|
114
|
+
phoneNumberValue?: string | null;
|
|
115
|
+
__typename?: "PhoneNumberFieldValueAndDefinition";
|
|
116
|
+
definition: {
|
|
117
|
+
__typename?: "PhoneNumberFieldDefinition";
|
|
118
|
+
title?: string | null;
|
|
119
|
+
key?: string | null;
|
|
120
|
+
id?: string | null;
|
|
121
|
+
};
|
|
122
|
+
} | {
|
|
123
|
+
valueId?: string | null;
|
|
124
|
+
stringValue?: string | null;
|
|
125
|
+
__typename?: "StringFieldValueAndDefinition";
|
|
126
|
+
definition: {
|
|
127
|
+
__typename?: "StringFieldDefinition";
|
|
128
|
+
title?: string | null;
|
|
129
|
+
key?: string | null;
|
|
130
|
+
id?: string | null;
|
|
131
|
+
};
|
|
132
|
+
} | {
|
|
133
|
+
valueId?: string | null;
|
|
134
|
+
fileId?: string | null;
|
|
135
|
+
fileName?: string | null;
|
|
136
|
+
downloadLink?: string | null;
|
|
137
|
+
__typename?: "FileFieldValueAndDefinition";
|
|
138
|
+
definition: {
|
|
139
|
+
__typename?: "FileFieldDefinition";
|
|
140
|
+
title?: string | null;
|
|
141
|
+
key?: string | null;
|
|
142
|
+
id?: string | null;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* This is the type for a data object that has custom fields.
|
|
147
|
+
* This is the type of the data that is returned from the GraphQL API when attaching custom fields to a query.
|
|
148
|
+
*/
|
|
149
|
+
export interface DataWithCustomFields {
|
|
150
|
+
customFields?: {
|
|
151
|
+
edges?: Array<{
|
|
152
|
+
node?: CustomFieldData | null;
|
|
153
|
+
} | null> | null;
|
|
154
|
+
} | null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* This is the type of the data that is returned from the GraphQL API for the custom field definitions.
|
|
158
|
+
* This is what is used to generate the ColumnDefinitions for the table.
|
|
159
|
+
*/
|
|
160
|
+
export type CustomFieldDefinitionEdgesContainer = {
|
|
161
|
+
edges?: Array<{
|
|
162
|
+
node?: CustomFieldDefinition | null;
|
|
163
|
+
} | null> | null;
|
|
164
|
+
} | null;
|
|
165
|
+
export type CustomFieldDefinitionArray = NonNullable<CustomFieldDefinitionEdgesContainer>["edges"];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FilterBarDefinition } from "@trackunit/filters-filter-bar";
|
|
2
|
+
import { SystemOfMeasurementType } from "@trackunit/iris-app-runtime-core-api";
|
|
3
|
+
import { ColumnDef } from "@trackunit/react-table";
|
|
4
|
+
import { CustomFieldData, CustomFieldDefinitionArray, DataWithCustomFields } from "./types";
|
|
5
|
+
export interface UseColumnDefinitionsFromCustomFieldDefinitionProps {
|
|
6
|
+
customFieldDefinitions?: CustomFieldDefinitionArray;
|
|
7
|
+
unitPreference: SystemOfMeasurementType | null | undefined;
|
|
8
|
+
language?: string;
|
|
9
|
+
filterBarDefinition?: FilterBarDefinition;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generates an array of table column definitions based on custom field definitions.
|
|
13
|
+
*
|
|
14
|
+
* @template TDataType - The data type with custom fields.
|
|
15
|
+
* @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
|
|
16
|
+
* @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useColumnDefinitionsFromCustomFieldDefinition: <TDataType extends DataWithCustomFields>({ customFieldDefinitions, unitPreference, language, filterBarDefinition, }: UseColumnDefinitionsFromCustomFieldDefinitionProps) => ColumnDef<TDataType, CustomFieldData | undefined>[];
|