@trackunit/custom-field-table-helpers 0.0.0-stage → 1.0.3
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/entry.js.map +1 -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
package/index.esm.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Temporal } from '@trackunit/date-and-time-utils';
|
|
3
|
+
import { getCustomFieldValueForDisplayInUI } from '@trackunit/iris-app-runtime-core';
|
|
4
|
+
import { ExternalLink } from '@trackunit/react-components';
|
|
5
|
+
import { TextCell, NumberCell, TagsCell, PlainDateCell, LinkCell, CheckboxCell } from '@trackunit/react-table-base-components';
|
|
6
|
+
import { useUnitTranslation } from '@trackunit/custom-field-components';
|
|
7
|
+
import { CustomFieldPrefix } from '@trackunit/filters-graphql-hook';
|
|
8
|
+
import { createColumnHelper } from '@trackunit/react-table';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
13
|
+
*/
|
|
14
|
+
const customFieldToCell = (customField, unitTranslation, unitPreference, language) => {
|
|
15
|
+
const type = customField.__typename;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case "BooleanFieldValueAndDefinition": {
|
|
18
|
+
const checked = customField.booleanValue ?? false;
|
|
19
|
+
return jsx(CheckboxCell, { checked: checked });
|
|
20
|
+
}
|
|
21
|
+
case "StringFieldValueAndDefinition":
|
|
22
|
+
return jsx(TextCell, { content: customField.stringValue?.toString() ?? "" });
|
|
23
|
+
case "EmailFieldValueAndDefinition":
|
|
24
|
+
return jsx(LinkCell, { link: customField.emailValue?.toString() ?? "", type: "EMAIL" });
|
|
25
|
+
case "PhoneNumberFieldValueAndDefinition":
|
|
26
|
+
return jsx(LinkCell, { link: customField.phoneNumberValue?.toString() ?? "", type: "PHONE" });
|
|
27
|
+
case "WebAddressFieldValueAndDefinition": {
|
|
28
|
+
return jsx(LinkCell, { link: customField.webAddressValue ?? "", type: "LINK" });
|
|
29
|
+
}
|
|
30
|
+
case "DateFieldValueAndDefinition": {
|
|
31
|
+
const date = customField.dateValue;
|
|
32
|
+
return date ? jsx(PlainDateCell, { date: Temporal.PlainDate.from(date), locale: language }) : null;
|
|
33
|
+
}
|
|
34
|
+
case "StringListFieldValueAndDefinition":
|
|
35
|
+
case "DropDownFieldValueAndDefinition": {
|
|
36
|
+
const tags = customField.stringArrayValue ?? [];
|
|
37
|
+
return jsx(TagsCell, { tags: tags });
|
|
38
|
+
}
|
|
39
|
+
case "JsonFieldValueAndDefinition":
|
|
40
|
+
return jsx(TextCell, { content: customField.jsonValue?.toString() ?? "" });
|
|
41
|
+
case "NumberFieldValueAndDefinition": {
|
|
42
|
+
const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
43
|
+
const value = customField.numberValue !== null && customField.numberValue !== undefined
|
|
44
|
+
? `${customField.numberValue}`
|
|
45
|
+
: undefined;
|
|
46
|
+
const updatedValue = getCustomFieldValueForDisplayInUI(value, unitType, unitPreference, language);
|
|
47
|
+
return jsx(NumberCell, { unit: unitTranslation(unitType), value: updatedValue });
|
|
48
|
+
}
|
|
49
|
+
case "MonetaryFieldValueAndDefinition":
|
|
50
|
+
return jsx(NumberCell, { value: customField.monetaryValue?.toString() ?? "" });
|
|
51
|
+
case "FileFieldValueAndDefinition": {
|
|
52
|
+
const fileName = customField.fileName;
|
|
53
|
+
const downloadLink = customField.downloadLink;
|
|
54
|
+
if (!fileName) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (!downloadLink) {
|
|
58
|
+
return jsx(TextCell, { content: fileName });
|
|
59
|
+
}
|
|
60
|
+
const handleClick = event => {
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
};
|
|
63
|
+
return (jsx(ExternalLink, { color: "neutral", href: downloadLink, onClick: handleClick, title: fileName, children: fileName }));
|
|
64
|
+
}
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`Unexpected value: ${type}`);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Takes a custom fields data object and returns a react node that can be used as a cell in a table.
|
|
72
|
+
*/
|
|
73
|
+
const customFieldToExportString = (customField, unitTranslation, unitPreference, language) => {
|
|
74
|
+
const type = customField.__typename;
|
|
75
|
+
switch (type) {
|
|
76
|
+
case "BooleanFieldValueAndDefinition": {
|
|
77
|
+
const checked = customField.booleanValue ?? false;
|
|
78
|
+
return checked;
|
|
79
|
+
}
|
|
80
|
+
case "StringFieldValueAndDefinition":
|
|
81
|
+
return customField.stringValue?.toString() ?? "";
|
|
82
|
+
case "EmailFieldValueAndDefinition":
|
|
83
|
+
return customField.emailValue?.toString() ?? "";
|
|
84
|
+
case "PhoneNumberFieldValueAndDefinition":
|
|
85
|
+
return customField.phoneNumberValue?.toString() ?? "";
|
|
86
|
+
case "WebAddressFieldValueAndDefinition": {
|
|
87
|
+
return customField.webAddressValue ?? "";
|
|
88
|
+
}
|
|
89
|
+
case "DateFieldValueAndDefinition": {
|
|
90
|
+
const date = customField.dateValue;
|
|
91
|
+
return date;
|
|
92
|
+
}
|
|
93
|
+
case "StringListFieldValueAndDefinition":
|
|
94
|
+
case "DropDownFieldValueAndDefinition": {
|
|
95
|
+
const tags = customField.stringArrayValue ?? [];
|
|
96
|
+
return tags.join(", ");
|
|
97
|
+
}
|
|
98
|
+
case "JsonFieldValueAndDefinition":
|
|
99
|
+
return customField.jsonValue?.toString() ?? "";
|
|
100
|
+
case "NumberFieldValueAndDefinition": {
|
|
101
|
+
const unitType = unitPreference === "SI" ? customField.definition.unitSi : customField.definition.unitUs;
|
|
102
|
+
const value = Boolean(customField.numberValue) ? `${customField.numberValue}` : undefined;
|
|
103
|
+
const updatedValue = getCustomFieldValueForDisplayInUI(value, unitType, unitPreference, language);
|
|
104
|
+
const unit = unitTranslation(unitType);
|
|
105
|
+
return unit ? `${updatedValue} ${unit}` : `${updatedValue}`;
|
|
106
|
+
}
|
|
107
|
+
case "MonetaryFieldValueAndDefinition":
|
|
108
|
+
return customField.monetaryValue?.toString() ?? "";
|
|
109
|
+
case "FileFieldValueAndDefinition":
|
|
110
|
+
return customField.fileName ?? "";
|
|
111
|
+
default:
|
|
112
|
+
throw new Error(`Unexpected value: ${type}`);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const AssetCustomFieldsFragmentDoc = {
|
|
117
|
+
kind: "Document",
|
|
118
|
+
definitions: [
|
|
119
|
+
{
|
|
120
|
+
kind: "FragmentDefinition",
|
|
121
|
+
name: { kind: "Name", value: "AssetCustomFields" },
|
|
122
|
+
typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Asset" } },
|
|
123
|
+
selectionSet: {
|
|
124
|
+
kind: "SelectionSet",
|
|
125
|
+
selections: [
|
|
126
|
+
{
|
|
127
|
+
kind: "Field",
|
|
128
|
+
name: { kind: "Name", value: "customFields" },
|
|
129
|
+
arguments: [
|
|
130
|
+
{
|
|
131
|
+
kind: "Argument",
|
|
132
|
+
name: { kind: "Name", value: "definitionIds" },
|
|
133
|
+
value: { kind: "Variable", name: { kind: "Name", value: "definitionIds" } },
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
selectionSet: {
|
|
137
|
+
kind: "SelectionSet",
|
|
138
|
+
selections: [
|
|
139
|
+
{
|
|
140
|
+
kind: "Field",
|
|
141
|
+
name: { kind: "Name", value: "edges" },
|
|
142
|
+
selectionSet: {
|
|
143
|
+
kind: "SelectionSet",
|
|
144
|
+
selections: [
|
|
145
|
+
{
|
|
146
|
+
kind: "Field",
|
|
147
|
+
name: { kind: "Name", value: "node" },
|
|
148
|
+
selectionSet: {
|
|
149
|
+
kind: "SelectionSet",
|
|
150
|
+
selections: [
|
|
151
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
152
|
+
{
|
|
153
|
+
kind: "Field",
|
|
154
|
+
name: { kind: "Name", value: "definition" },
|
|
155
|
+
selectionSet: {
|
|
156
|
+
kind: "SelectionSet",
|
|
157
|
+
selections: [
|
|
158
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
159
|
+
{ kind: "Field", name: { kind: "Name", value: "title" } },
|
|
160
|
+
{ kind: "Field", name: { kind: "Name", value: "key" } },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{ kind: "Field", name: { kind: "Name", value: "valueId" } },
|
|
165
|
+
{
|
|
166
|
+
kind: "InlineFragment",
|
|
167
|
+
typeCondition: {
|
|
168
|
+
kind: "NamedType",
|
|
169
|
+
name: { kind: "Name", value: "BooleanFieldValueAndDefinition" },
|
|
170
|
+
},
|
|
171
|
+
selectionSet: {
|
|
172
|
+
kind: "SelectionSet",
|
|
173
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "booleanValue" } }],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
kind: "InlineFragment",
|
|
178
|
+
typeCondition: {
|
|
179
|
+
kind: "NamedType",
|
|
180
|
+
name: { kind: "Name", value: "DateFieldValueAndDefinition" },
|
|
181
|
+
},
|
|
182
|
+
selectionSet: {
|
|
183
|
+
kind: "SelectionSet",
|
|
184
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "dateValue" } }],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
kind: "InlineFragment",
|
|
189
|
+
typeCondition: {
|
|
190
|
+
kind: "NamedType",
|
|
191
|
+
name: { kind: "Name", value: "DropDownFieldValueAndDefinition" },
|
|
192
|
+
},
|
|
193
|
+
selectionSet: {
|
|
194
|
+
kind: "SelectionSet",
|
|
195
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "stringArrayValue" } }],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
kind: "InlineFragment",
|
|
200
|
+
typeCondition: {
|
|
201
|
+
kind: "NamedType",
|
|
202
|
+
name: { kind: "Name", value: "EmailFieldValueAndDefinition" },
|
|
203
|
+
},
|
|
204
|
+
selectionSet: {
|
|
205
|
+
kind: "SelectionSet",
|
|
206
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "emailValue" } }],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
kind: "InlineFragment",
|
|
211
|
+
typeCondition: {
|
|
212
|
+
kind: "NamedType",
|
|
213
|
+
name: { kind: "Name", value: "NumberFieldValueAndDefinition" },
|
|
214
|
+
},
|
|
215
|
+
selectionSet: {
|
|
216
|
+
kind: "SelectionSet",
|
|
217
|
+
selections: [
|
|
218
|
+
{
|
|
219
|
+
kind: "Field",
|
|
220
|
+
name: { kind: "Name", value: "definition" },
|
|
221
|
+
selectionSet: {
|
|
222
|
+
kind: "SelectionSet",
|
|
223
|
+
selections: [
|
|
224
|
+
{ kind: "Field", name: { kind: "Name", value: "unitSi" } },
|
|
225
|
+
{ kind: "Field", name: { kind: "Name", value: "unitUs" } },
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
kind: "Field",
|
|
231
|
+
name: { kind: "Name", value: "numberValue" },
|
|
232
|
+
arguments: [
|
|
233
|
+
{
|
|
234
|
+
kind: "Argument",
|
|
235
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
236
|
+
value: {
|
|
237
|
+
kind: "Variable",
|
|
238
|
+
name: { kind: "Name", value: "systemOfMeasurement" },
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
kind: "InlineFragment",
|
|
248
|
+
typeCondition: {
|
|
249
|
+
kind: "NamedType",
|
|
250
|
+
name: { kind: "Name", value: "PhoneNumberFieldValueAndDefinition" },
|
|
251
|
+
},
|
|
252
|
+
selectionSet: {
|
|
253
|
+
kind: "SelectionSet",
|
|
254
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "phoneNumberValue" } }],
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
kind: "InlineFragment",
|
|
259
|
+
typeCondition: {
|
|
260
|
+
kind: "NamedType",
|
|
261
|
+
name: { kind: "Name", value: "StringFieldValueAndDefinition" },
|
|
262
|
+
},
|
|
263
|
+
selectionSet: {
|
|
264
|
+
kind: "SelectionSet",
|
|
265
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "stringValue" } }],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
kind: "InlineFragment",
|
|
270
|
+
typeCondition: {
|
|
271
|
+
kind: "NamedType",
|
|
272
|
+
name: { kind: "Name", value: "WebAddressFieldValueAndDefinition" },
|
|
273
|
+
},
|
|
274
|
+
selectionSet: {
|
|
275
|
+
kind: "SelectionSet",
|
|
276
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "webAddressValue" } }],
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
kind: "InlineFragment",
|
|
281
|
+
typeCondition: {
|
|
282
|
+
kind: "NamedType",
|
|
283
|
+
name: { kind: "Name", value: "JsonFieldValueAndDefinition" },
|
|
284
|
+
},
|
|
285
|
+
selectionSet: {
|
|
286
|
+
kind: "SelectionSet",
|
|
287
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "jsonValue" } }],
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
kind: "InlineFragment",
|
|
292
|
+
typeCondition: {
|
|
293
|
+
kind: "NamedType",
|
|
294
|
+
name: { kind: "Name", value: "MonetaryFieldValueAndDefinition" },
|
|
295
|
+
},
|
|
296
|
+
selectionSet: {
|
|
297
|
+
kind: "SelectionSet",
|
|
298
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "monetaryValue" } }],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
kind: "InlineFragment",
|
|
303
|
+
typeCondition: {
|
|
304
|
+
kind: "NamedType",
|
|
305
|
+
name: { kind: "Name", value: "StringListFieldValueAndDefinition" },
|
|
306
|
+
},
|
|
307
|
+
selectionSet: {
|
|
308
|
+
kind: "SelectionSet",
|
|
309
|
+
selections: [{ kind: "Field", name: { kind: "Name", value: "stringArrayValue" } }],
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
kind: "InlineFragment",
|
|
314
|
+
typeCondition: {
|
|
315
|
+
kind: "NamedType",
|
|
316
|
+
name: { kind: "Name", value: "FileFieldValueAndDefinition" },
|
|
317
|
+
},
|
|
318
|
+
selectionSet: {
|
|
319
|
+
kind: "SelectionSet",
|
|
320
|
+
selections: [
|
|
321
|
+
{ kind: "Field", name: { kind: "Name", value: "fileName" } },
|
|
322
|
+
{ kind: "Field", name: { kind: "Name", value: "downloadLink" } },
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Generates an array of table column definitions based on custom field definitions.
|
|
343
|
+
*
|
|
344
|
+
* @template TDataType - The data type with custom fields.
|
|
345
|
+
* @param {CustomFieldDefinitionArray} customFieldDefinitions - An array of custom field definitions.
|
|
346
|
+
* @returns {ColumnDef<TDataType, CustomFieldData | undefined>[]} - An array of column definitions.
|
|
347
|
+
*/
|
|
348
|
+
const useColumnDefinitionsFromCustomFieldDefinition = ({ customFieldDefinitions, unitPreference, language, filterBarDefinition, }) => {
|
|
349
|
+
const { unitTranslation } = useUnitTranslation();
|
|
350
|
+
return useMemo(() => {
|
|
351
|
+
const columnHelper = createColumnHelper();
|
|
352
|
+
const result = [];
|
|
353
|
+
customFieldDefinitions?.forEach(customFieldDefinition => {
|
|
354
|
+
if (customFieldDefinition?.node &&
|
|
355
|
+
customFieldDefinition.node.id &&
|
|
356
|
+
customFieldDefinition.node.title &&
|
|
357
|
+
customFieldDefinition.node.__typename) {
|
|
358
|
+
const id = CustomFieldPrefix + customFieldDefinition.node.id;
|
|
359
|
+
const isKeyFound = filterBarDefinition ? !!filterBarDefinition[id] : false;
|
|
360
|
+
const column = columnHelper.accessor(data => data.customFields?.edges?.find(field => {
|
|
361
|
+
return field?.node?.definition.id === customFieldDefinition.node?.id;
|
|
362
|
+
})?.node, {
|
|
363
|
+
header: customFieldDefinition.node.title,
|
|
364
|
+
id: customFieldDefinition.node.id,
|
|
365
|
+
enableSorting: customFieldDefinition.node.__typename !== "DropDownFieldDefinition" &&
|
|
366
|
+
customFieldDefinition.node.__typename !== "StringListFieldDefinition" &&
|
|
367
|
+
customFieldDefinition.node.__typename !== "FileFieldDefinition",
|
|
368
|
+
meta: {
|
|
369
|
+
fragment: AssetCustomFieldsFragmentDoc,
|
|
370
|
+
hiddenByDefault: true,
|
|
371
|
+
isCustomField: { definitionId: customFieldDefinition.node.id },
|
|
372
|
+
filterName: isKeyFound && filterBarDefinition ? filterBarDefinition[id]?.filterKey : undefined,
|
|
373
|
+
export: {
|
|
374
|
+
accessor: "customFields.edges[].node",
|
|
375
|
+
transformer: { type: "customFields", id: customFieldDefinition.node.id },
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
cell: cell => {
|
|
379
|
+
const cellValue = cell.getValue();
|
|
380
|
+
return cellValue ? customFieldToCell(cellValue, unitTranslation, unitPreference, language) : "";
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
result.push(column);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return result;
|
|
387
|
+
}, [filterBarDefinition, customFieldDefinitions, unitTranslation, unitPreference, language]);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export { customFieldToCell, customFieldToExportString, useColumnDefinitionsFromCustomFieldDefinition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/custom-field/table-helpers/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|
package/migrations.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-table-helpers",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"repository": "https://github.com/Trackunit/manager",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24.x"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@graphql-typed-document-node/core": "^3.2.0",
|
|
11
|
+
"@trackunit/custom-field-components": "2.32.7",
|
|
12
|
+
"@trackunit/date-and-time-utils": "1.20.25",
|
|
13
|
+
"@trackunit/filters-filter-bar": "2.17.17",
|
|
14
|
+
"@trackunit/filters-graphql-hook": "2.32.7",
|
|
15
|
+
"@trackunit/iris-app-api": "2.12.28",
|
|
16
|
+
"@trackunit/iris-app-runtime-core": "1.28.15",
|
|
17
|
+
"@trackunit/iris-app-runtime-core-api": "1.27.15",
|
|
18
|
+
"@trackunit/react-components": "6.0.15",
|
|
19
|
+
"@trackunit/react-table": "2.18.16",
|
|
20
|
+
"@trackunit/react-table-base-components": "2.19.16"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@apollo/client": "^3.13.8",
|
|
24
|
+
"@tanstack/react-router": "^1.114.29",
|
|
25
|
+
"@tanstack/react-table": "^8.20.6",
|
|
26
|
+
"graphql": "^16.10.0",
|
|
27
|
+
"react": "^19.0.0",
|
|
28
|
+
"react-hook-form": "^7.62.0"
|
|
29
|
+
},
|
|
30
|
+
"migrations": "./migrations.json",
|
|
31
|
+
"module": "./index.esm.js",
|
|
32
|
+
"main": "./index.cjs.js",
|
|
33
|
+
"types": "./index.d.ts"
|
|
6
34
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
import { Incremental } from './graphql';
|
|
3
|
+
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
|
|
4
|
+
' $fragmentName'?: infer TKey;
|
|
5
|
+
}] ? TKey extends string ? {
|
|
6
|
+
' $fragmentRefs'?: {
|
|
7
|
+
[key in TKey]: TType;
|
|
8
|
+
};
|
|
9
|
+
} : never : never : never;
|
|
10
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
|
|
11
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined): TType | undefined;
|
|
12
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null): TType | null;
|
|
13
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
|
|
14
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>): Array<TType>;
|
|
15
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): Array<TType> | null | undefined;
|
|
16
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
|
|
17
|
+
export declare function getFragmentData<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
|
|
18
|
+
export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
|
|
19
|
+
export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as types from './graphql';
|
|
2
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
/**
|
|
4
|
+
* Map of all GraphQL operations in the project.
|
|
5
|
+
*
|
|
6
|
+
* This map has several performance disadvantages:
|
|
7
|
+
* 1. It is not tree-shakeable, so it will include all operations in the project.
|
|
8
|
+
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
|
|
9
|
+
* 3. It does not support dead code elimination, so it will add unused operations.
|
|
10
|
+
*
|
|
11
|
+
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
12
|
+
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
|
|
13
|
+
*/
|
|
14
|
+
declare const documents: {
|
|
15
|
+
"fragment AssetCustomFields on Asset {\n customFields(definitionIds: $definitionIds) {\n edges {\n node {\n __typename\n definition {\n id\n title\n key\n }\n valueId\n ... on BooleanFieldValueAndDefinition {\n booleanValue\n }\n ... on DateFieldValueAndDefinition {\n dateValue\n }\n ... on DropDownFieldValueAndDefinition {\n stringArrayValue\n }\n ... on EmailFieldValueAndDefinition {\n emailValue\n }\n ... on NumberFieldValueAndDefinition {\n definition {\n unitSi\n unitUs\n }\n numberValue(systemOfMeasurement: $systemOfMeasurement)\n }\n ... on PhoneNumberFieldValueAndDefinition {\n phoneNumberValue\n }\n ... on StringFieldValueAndDefinition {\n stringValue\n }\n ... on WebAddressFieldValueAndDefinition {\n webAddressValue\n }\n ... on JsonFieldValueAndDefinition {\n jsonValue\n }\n ... on MonetaryFieldValueAndDefinition {\n monetaryValue\n }\n ... on StringListFieldValueAndDefinition {\n stringArrayValue\n }\n ... on FileFieldValueAndDefinition {\n fileName\n downloadLink\n }\n }\n }\n }\n}": DocumentNode<types.AssetCustomFieldsFragment, unknown>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The query argument is unknown!
|
|
27
|
+
* Please regenerate the types.
|
|
28
|
+
*/
|
|
29
|
+
export declare function graphql(source: string): unknown;
|
|
30
|
+
/**
|
|
31
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
32
|
+
*/
|
|
33
|
+
export declare function graphql(source: "fragment AssetCustomFields on Asset {\n customFields(definitionIds: $definitionIds) {\n edges {\n node {\n __typename\n definition {\n id\n title\n key\n }\n valueId\n ... on BooleanFieldValueAndDefinition {\n booleanValue\n }\n ... on DateFieldValueAndDefinition {\n dateValue\n }\n ... on DropDownFieldValueAndDefinition {\n stringArrayValue\n }\n ... on EmailFieldValueAndDefinition {\n emailValue\n }\n ... on NumberFieldValueAndDefinition {\n definition {\n unitSi\n unitUs\n }\n numberValue(systemOfMeasurement: $systemOfMeasurement)\n }\n ... on PhoneNumberFieldValueAndDefinition {\n phoneNumberValue\n }\n ... on StringFieldValueAndDefinition {\n stringValue\n }\n ... on WebAddressFieldValueAndDefinition {\n webAddressValue\n }\n ... on JsonFieldValueAndDefinition {\n jsonValue\n }\n ... on MonetaryFieldValueAndDefinition {\n monetaryValue\n }\n ... on StringListFieldValueAndDefinition {\n stringArrayValue\n }\n ... on FileFieldValueAndDefinition {\n fileName\n downloadLink\n }\n }\n }\n }\n}"): (typeof documents)["fragment AssetCustomFields on Asset {\n customFields(definitionIds: $definitionIds) {\n edges {\n node {\n __typename\n definition {\n id\n title\n key\n }\n valueId\n ... on BooleanFieldValueAndDefinition {\n booleanValue\n }\n ... on DateFieldValueAndDefinition {\n dateValue\n }\n ... on DropDownFieldValueAndDefinition {\n stringArrayValue\n }\n ... on EmailFieldValueAndDefinition {\n emailValue\n }\n ... on NumberFieldValueAndDefinition {\n definition {\n unitSi\n unitUs\n }\n numberValue(systemOfMeasurement: $systemOfMeasurement)\n }\n ... on PhoneNumberFieldValueAndDefinition {\n phoneNumberValue\n }\n ... on StringFieldValueAndDefinition {\n stringValue\n }\n ... on WebAddressFieldValueAndDefinition {\n webAddressValue\n }\n ... on JsonFieldValueAndDefinition {\n jsonValue\n }\n ... on MonetaryFieldValueAndDefinition {\n monetaryValue\n }\n ... on StringListFieldValueAndDefinition {\n stringArrayValue\n }\n ... on FileFieldValueAndDefinition {\n fileName\n downloadLink\n }\n }\n }\n }\n}"];
|
|
34
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|
|
35
|
+
export {};
|