@teselagen/ui 0.7.34 → 0.7.36

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 (161) hide show
  1. package/isBeingCalledExcessively.js +2 -0
  2. package/package.json +1 -1
  3. package/style.css +26 -10
  4. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
  5. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
  6. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
  7. package/src/AdvancedOptions.js +0 -33
  8. package/src/AdvancedOptions.spec.js +0 -26
  9. package/src/AssignDefaultsModeContext.js +0 -22
  10. package/src/AsyncValidateFieldSpinner/index.js +0 -12
  11. package/src/BlueprintError/index.js +0 -14
  12. package/src/BounceLoader/index.js +0 -16
  13. package/src/BounceLoader/style.css +0 -45
  14. package/src/CollapsibleCard/index.js +0 -68
  15. package/src/CollapsibleCard/style.css +0 -23
  16. package/src/DNALoader/index.js +0 -20
  17. package/src/DNALoader/style.css +0 -251
  18. package/src/DataTable/CellDragHandle.js +0 -132
  19. package/src/DataTable/ColumnFilterMenu.js +0 -62
  20. package/src/DataTable/Columns.js +0 -979
  21. package/src/DataTable/DisabledLoadingComponent.js +0 -15
  22. package/src/DataTable/DisplayOptions.js +0 -199
  23. package/src/DataTable/DropdownCell.js +0 -61
  24. package/src/DataTable/EditableCell.js +0 -44
  25. package/src/DataTable/FilterAndSortMenu.js +0 -388
  26. package/src/DataTable/PagingTool.js +0 -225
  27. package/src/DataTable/RenderCell.js +0 -191
  28. package/src/DataTable/SearchBar.js +0 -69
  29. package/src/DataTable/SortableColumns.js +0 -100
  30. package/src/DataTable/TableFormTrackerContext.js +0 -10
  31. package/src/DataTable/ThComponent.js +0 -44
  32. package/src/DataTable/dataTableEnhancer.js +0 -41
  33. package/src/DataTable/defaultFormatters.js +0 -32
  34. package/src/DataTable/defaultValidators.js +0 -40
  35. package/src/DataTable/editCellHelper.js +0 -44
  36. package/src/DataTable/getCellVal.js +0 -20
  37. package/src/DataTable/getVals.js +0 -8
  38. package/src/DataTable/index.js +0 -3209
  39. package/src/DataTable/isTruthy.js +0 -12
  40. package/src/DataTable/isValueEmpty.js +0 -3
  41. package/src/DataTable/style.css +0 -608
  42. package/src/DataTable/utils/convertSchema.js +0 -69
  43. package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
  44. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
  45. package/src/DataTable/utils/formatPasteData.js +0 -16
  46. package/src/DataTable/utils/getAllRows.js +0 -11
  47. package/src/DataTable/utils/getCellCopyText.js +0 -7
  48. package/src/DataTable/utils/getCellInfo.js +0 -36
  49. package/src/DataTable/utils/getFieldPathToField.js +0 -7
  50. package/src/DataTable/utils/getIdOrCodeOrIndex.js +0 -9
  51. package/src/DataTable/utils/getLastSelectedEntity.js +0 -11
  52. package/src/DataTable/utils/getNewEntToSelect.js +0 -25
  53. package/src/DataTable/utils/getRowCopyText.js +0 -28
  54. package/src/DataTable/utils/getTableConfigFromStorage.js +0 -5
  55. package/src/DataTable/utils/handleCopyColumn.js +0 -21
  56. package/src/DataTable/utils/handleCopyHelper.js +0 -15
  57. package/src/DataTable/utils/handleCopyRows.js +0 -23
  58. package/src/DataTable/utils/handleCopyTable.js +0 -16
  59. package/src/DataTable/utils/index.js +0 -55
  60. package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
  61. package/src/DataTable/utils/isBottomRightCornerOfRectangle.js +0 -20
  62. package/src/DataTable/utils/isEntityClean.js +0 -15
  63. package/src/DataTable/utils/primarySelectedValue.js +0 -1
  64. package/src/DataTable/utils/queryParams.js +0 -350
  65. package/src/DataTable/utils/removeCleanRows.js +0 -22
  66. package/src/DataTable/utils/rowClick.js +0 -181
  67. package/src/DataTable/utils/selection.js +0 -8
  68. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
  69. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
  70. package/src/DataTable/utils/useTableEntities.js +0 -38
  71. package/src/DataTable/utils/utils.js +0 -37
  72. package/src/DataTable/utils/withSelectedEntities.js +0 -65
  73. package/src/DataTable/utils/withTableParams.js +0 -288
  74. package/src/DataTable/validateTableWideErrors.js +0 -160
  75. package/src/DataTable/viewColumn.js +0 -97
  76. package/src/DialogFooter/index.js +0 -86
  77. package/src/DialogFooter/style.css +0 -9
  78. package/src/DropdownButton.js +0 -36
  79. package/src/FillWindow.css +0 -6
  80. package/src/FillWindow.js +0 -69
  81. package/src/FormComponents/FormSeparator.js +0 -9
  82. package/src/FormComponents/LoadingDots.js +0 -14
  83. package/src/FormComponents/Uploader.js +0 -1278
  84. package/src/FormComponents/getNewName.js +0 -31
  85. package/src/FormComponents/index.js +0 -1266
  86. package/src/FormComponents/itemUpload.js +0 -84
  87. package/src/FormComponents/sortify.js +0 -73
  88. package/src/FormComponents/style.css +0 -275
  89. package/src/FormComponents/tryToMatchSchemas.js +0 -264
  90. package/src/FormComponents/utils.js +0 -6
  91. package/src/HotkeysDialog/index.js +0 -79
  92. package/src/HotkeysDialog/style.css +0 -54
  93. package/src/InfoHelper/index.js +0 -78
  94. package/src/InfoHelper/style.css +0 -7
  95. package/src/IntentText/index.js +0 -18
  96. package/src/Loading/index.js +0 -70
  97. package/src/Loading/style.css +0 -4
  98. package/src/MatchHeaders.js +0 -234
  99. package/src/MenuBar/index.js +0 -423
  100. package/src/MenuBar/style.css +0 -45
  101. package/src/PromptUnsavedChanges/index.js +0 -38
  102. package/src/ResizableDraggableDialog/index.js +0 -141
  103. package/src/ResizableDraggableDialog/style.css +0 -42
  104. package/src/ScrollToTop/index.js +0 -72
  105. package/src/SimpleStepViz.js +0 -22
  106. package/src/Tag.js +0 -112
  107. package/src/TagSelect/index.js +0 -69
  108. package/src/TagSelect/style.css +0 -13
  109. package/src/TgHtmlSelect/index.js +0 -20
  110. package/src/TgSelect/index.js +0 -537
  111. package/src/TgSelect/style.css +0 -61
  112. package/src/TgSuggest/index.js +0 -124
  113. package/src/Timeline/TimelineEvent.js +0 -31
  114. package/src/Timeline/index.js +0 -15
  115. package/src/Timeline/style.css +0 -29
  116. package/src/UploadCsvWizard.css +0 -4
  117. package/src/UploadCsvWizard.js +0 -719
  118. package/src/autoTooltip.js +0 -201
  119. package/src/constants.js +0 -1
  120. package/src/customIcons.js +0 -361
  121. package/src/enhancers/withDialog/index.js +0 -196
  122. package/src/enhancers/withDialog/tg_modalState.js +0 -47
  123. package/src/enhancers/withField.js +0 -20
  124. package/src/enhancers/withFields.js +0 -11
  125. package/src/enhancers/withLocalStorage.js +0 -11
  126. package/src/index.js +0 -88
  127. package/src/rerenderOnWindowResize.js +0 -26
  128. package/src/showAppSpinner.js +0 -12
  129. package/src/showConfirmationDialog/index.js +0 -148
  130. package/src/showDialogOnDocBody.js +0 -33
  131. package/src/style.css +0 -265
  132. package/src/throwFormError.js +0 -16
  133. package/src/toastr.js +0 -148
  134. package/src/typeToCommonType.js +0 -6
  135. package/src/useDialog.js +0 -63
  136. package/src/utils/adHoc.js +0 -10
  137. package/src/utils/basicHandleActionsWithFullState.js +0 -14
  138. package/src/utils/browserUtils.js +0 -3
  139. package/src/utils/combineReducersWithFullState.js +0 -14
  140. package/src/utils/commandControls.js +0 -82
  141. package/src/utils/commandUtils.js +0 -112
  142. package/src/utils/determineBlackOrWhiteTextColor.js +0 -4
  143. package/src/utils/getDayjsFormatter.js +0 -35
  144. package/src/utils/getTextFromEl.js +0 -28
  145. package/src/utils/handlerHelpers.js +0 -24
  146. package/src/utils/hooks/index.js +0 -1
  147. package/src/utils/hooks/useDeepEqualMemo.js +0 -15
  148. package/src/utils/hooks/useStableReference.js +0 -9
  149. package/src/utils/hotkeyUtils.js +0 -131
  150. package/src/utils/isBeingCalledExcessively.js +0 -24
  151. package/src/utils/menuUtils.js +0 -433
  152. package/src/utils/popoverOverflowModifiers.js +0 -11
  153. package/src/utils/pureNoFunc.js +0 -31
  154. package/src/utils/renderOnDoc.js +0 -32
  155. package/src/utils/showProgressToast.js +0 -22
  156. package/src/utils/tagUtils.js +0 -45
  157. package/src/utils/tgFormValues.js +0 -35
  158. package/src/utils/useTraceUpdate.js +0 -19
  159. package/src/utils/withSelectTableRecords.js +0 -43
  160. package/src/utils/withStore.js +0 -10
  161. package/src/wrapDialog.js +0 -116
@@ -1,587 +0,0 @@
1
- import { filterLocalEntitiesToHasura } from "./filterLocalEntitiesToHasura";
2
-
3
- describe("filterLocalEntitiesToHasura", () => {
4
- const records = [
5
- {
6
- id: 123,
7
- name: "John Doe",
8
- age: 30,
9
- is_active: true,
10
- city: "London",
11
-
12
- tags: ["programming", "javascript"],
13
- email: "john@example.com",
14
- data: { category: "A", type: "X" },
15
- username: "john123"
16
- },
17
- {
18
- id: 456,
19
- name: "Jane Smith",
20
- age: 25,
21
- is_active: false,
22
- city: "Paris",
23
- tags: ["javascript", "python"],
24
- email: null,
25
- data: { category: "B", type: "Y" },
26
- username: "jane456"
27
- },
28
- {
29
- id: 789,
30
- name: "Alice Johnson",
31
- age: 35,
32
- is_active: true,
33
- city: "London",
34
- tags: ["programming", "python", "java"],
35
- email: "alice@example.com",
36
- data: { category: "A", type: "Z" },
37
- username: "alice789"
38
- },
39
- {
40
- id: 101,
41
- name: "Bob Williams",
42
- age: 20,
43
- is_active: false,
44
- city: "New York",
45
- tags: ["java"],
46
- email: "bob@example.com",
47
- data: { category: "C", type: "X" },
48
- username: "bob101"
49
- }
50
- ];
51
-
52
- it("should filter by _eq", () => {
53
- const result = filterLocalEntitiesToHasura(records, {
54
- where: { id: { _eq: 123 } }
55
- });
56
- expect(result.entities).toEqual([records[0]]);
57
- expect(result.entitiesAcrossPages).toEqual([records[0]]);
58
- expect(result.entityCount).toBe(1);
59
- });
60
-
61
- it("should filter by _neq", () => {
62
- const result = filterLocalEntitiesToHasura(records, {
63
- where: { id: { _neq: 123 } }
64
- });
65
- expect(result.entities).toEqual(records.slice(1));
66
- expect(result.entitiesAcrossPages).toEqual(records.slice(1));
67
- expect(result.entityCount).toBe(3);
68
- });
69
-
70
- it("should filter by _gt", () => {
71
- const result = filterLocalEntitiesToHasura(records, {
72
- where: { age: { _gt: 30 } }
73
- });
74
- expect(result.entities).toEqual([records[2]]);
75
- expect(result.entitiesAcrossPages).toEqual([records[2]]);
76
- expect(result.entityCount).toBe(1);
77
- });
78
-
79
- it("should filter by _gte", () => {
80
- const result = filterLocalEntitiesToHasura(records, {
81
- where: { age: { _gte: 30 } }
82
- });
83
- expect(result.entities).toEqual([records[0], records[2]]);
84
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
85
- expect(result.entityCount).toBe(2);
86
- });
87
-
88
- it("should filter by _lt", () => {
89
- const result = filterLocalEntitiesToHasura(records, {
90
- where: { age: { _lt: 25 } }
91
- });
92
- expect(result.entities).toEqual([records[3]]);
93
- expect(result.entitiesAcrossPages).toEqual([records[3]]);
94
- expect(result.entityCount).toBe(1);
95
- });
96
-
97
- it("should filter by _lte", () => {
98
- const result = filterLocalEntitiesToHasura(records, {
99
- where: { age: { _lte: 25 } }
100
- });
101
- expect(result.entities).toEqual([records[1], records[3]]);
102
- expect(result.entitiesAcrossPages).toEqual([records[1], records[3]]);
103
- expect(result.entityCount).toBe(2);
104
- });
105
-
106
- it("should filter by _like", () => {
107
- const result = filterLocalEntitiesToHasura(records, {
108
- where: { name: { _like: "%John%" } }
109
- });
110
- expect(result.entities).toEqual([records[0], records[2]]);
111
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
112
- expect(result.entityCount).toBe(2);
113
- });
114
-
115
- it("should filter by _ilike", () => {
116
- const result = filterLocalEntitiesToHasura(records, {
117
- where: { name: { _ilike: "%john%" } }
118
- });
119
- expect(result.entities).toEqual([records[0], records[2]]);
120
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
121
- expect(result.entityCount).toBe(2);
122
- });
123
-
124
- it("should filter by _nlike", () => {
125
- const result = filterLocalEntitiesToHasura(records, {
126
- where: { name: { _nlike: "%John%" } }
127
- });
128
- expect(result.entities).toEqual([records[1], records[3]]);
129
- expect(result.entitiesAcrossPages).toEqual([records[1], records[3]]);
130
- expect(result.entityCount).toBe(2);
131
- });
132
-
133
- it("should filter by _nilike", () => {
134
- const result = filterLocalEntitiesToHasura(records, {
135
- where: { name: { _nilike: "%john%" } }
136
- });
137
- expect(result.entities).toEqual([records[1], records[3]]);
138
- expect(result.entitiesAcrossPages).toEqual([records[1], records[3]]);
139
- expect(result.entityCount).toBe(2);
140
- });
141
-
142
- it("should filter by _starts_with", () => {
143
- const result = filterLocalEntitiesToHasura(records, {
144
- where: { name: { _starts_with: "John" } }
145
- });
146
- expect(result.entities).toEqual([records[0]]);
147
- expect(result.entitiesAcrossPages).toEqual([records[0]]);
148
- expect(result.entityCount).toBe(1);
149
- });
150
-
151
- it("should filter by _ends_with", () => {
152
- const result = filterLocalEntitiesToHasura(records, {
153
- where: { name: { _ends_with: "Doe" } }
154
- });
155
- expect(result.entities).toEqual([records[0]]);
156
- expect(result.entitiesAcrossPages).toEqual([records[0]]);
157
- expect(result.entityCount).toBe(1);
158
- });
159
-
160
- it("should filter by _is_null", () => {
161
- const result = filterLocalEntitiesToHasura(records, {
162
- where: { email: { _is_null: true } }
163
- });
164
- expect(result.entities).toEqual([records[1]]);
165
- expect(result.entitiesAcrossPages).toEqual([records[1]]);
166
- expect(result.entityCount).toBe(1);
167
- });
168
-
169
- it("should filter by _is_null false", () => {
170
- const result = filterLocalEntitiesToHasura(records, {
171
- where: { email: { _is_null: false } }
172
- });
173
- expect(result.entities).toEqual([records[0], records[2], records[3]]);
174
- expect(result.entitiesAcrossPages).toEqual([
175
- records[0],
176
- records[2],
177
- records[3]
178
- ]);
179
- expect(result.entityCount).toBe(3);
180
- });
181
-
182
- it("should filter by _and", () => {
183
- const result = filterLocalEntitiesToHasura(records, {
184
- where: {
185
- _and: [{ age: { _gt: 25 } }, { city: { _eq: "London" } }]
186
- }
187
- });
188
- expect(result.entities).toEqual([records[0], records[2]]);
189
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
190
- expect(result.entityCount).toBe(2);
191
- });
192
-
193
- it("should filter by _or", () => {
194
- const result = filterLocalEntitiesToHasura(records, {
195
- where: {
196
- _or: [{ city: { _eq: "London" } }, { city: { _eq: "Paris" } }]
197
- }
198
- });
199
- expect(result.entities).toEqual([records[0], records[1], records[2]]);
200
- expect(result.entitiesAcrossPages).toEqual([
201
- records[0],
202
- records[1],
203
- records[2]
204
- ]);
205
- expect(result.entityCount).toBe(3);
206
- });
207
-
208
- it("should filter by _not", () => {
209
- const result = filterLocalEntitiesToHasura(records, {
210
- where: {
211
- _not: { is_active: { _eq: true } }
212
- }
213
- });
214
- expect(result.entities).toEqual([records[1], records[3]]);
215
- expect(result.entitiesAcrossPages).toEqual([records[1], records[3]]);
216
- expect(result.entityCount).toBe(2);
217
- });
218
-
219
- it("should filter by _contains", () => {
220
- const result = filterLocalEntitiesToHasura(records, {
221
- where: {
222
- tags: { _contains: ["programming", "javascript"] }
223
- }
224
- });
225
- expect(result.entities).toEqual([records[0]]);
226
- expect(result.entitiesAcrossPages).toEqual([records[0]]);
227
- expect(result.entityCount).toBe(1);
228
- });
229
-
230
- it("should filter by _contained_in", () => {
231
- const result = filterLocalEntitiesToHasura(records, {
232
- where: {
233
- tags: { _contained_in: ["programming", "javascript", "python", "java"] }
234
- }
235
- });
236
- expect(result.entities).toEqual(records);
237
- expect(result.entitiesAcrossPages).toEqual(records);
238
- expect(result.entityCount).toBe(4);
239
- });
240
-
241
- it("should filter by _has_key", () => {
242
- const result = filterLocalEntitiesToHasura(records, {
243
- where: { data: { _has_key: "category" } }
244
- });
245
- expect(result.entities).toEqual(records);
246
- expect(result.entitiesAcrossPages).toEqual(records);
247
- expect(result.entityCount).toBe(4);
248
- });
249
-
250
- it("should filter by _has_keys_any", () => {
251
- const result = filterLocalEntitiesToHasura(records, {
252
- where: {
253
- data: { _has_keys_any: ["category", "missingKey"] }
254
- }
255
- });
256
- expect(result.entities).toEqual(records);
257
- expect(result.entitiesAcrossPages).toEqual(records);
258
- expect(result.entityCount).toBe(4);
259
- });
260
-
261
- it("should filter by _has_keys_all", () => {
262
- const result = filterLocalEntitiesToHasura(records, {
263
- where: {
264
- data: { _has_keys_all: ["category", "type"] }
265
- }
266
- });
267
- expect(result.entities).toEqual(records);
268
- expect(result.entitiesAcrossPages).toEqual(records);
269
- expect(result.entityCount).toBe(4);
270
- });
271
-
272
- it("should filter by _similar", () => {
273
- const result = filterLocalEntitiesToHasura(records, {
274
- where: {
275
- username: { _similar: "(john|alice)%" }
276
- }
277
- });
278
- expect(result.entities).toEqual([records[0], records[2]]);
279
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
280
- expect(result.entityCount).toBe(2);
281
- });
282
-
283
- it("should filter by range _gte and _lte", () => {
284
- const result = filterLocalEntitiesToHasura(records, {
285
- where: { age: { _gte: 25, _lte: 30 } }
286
- });
287
- expect(result.entities).toEqual([records[0], records[1]]);
288
- expect(result.entitiesAcrossPages).toEqual([records[0], records[1]]);
289
- expect(result.entityCount).toBe(2);
290
- });
291
-
292
- it("should filter by range _gt and _lt", () => {
293
- const result = filterLocalEntitiesToHasura(records, {
294
- where: { age: { _gt: 25, _lt: 35 } }
295
- });
296
- expect(result.entities).toEqual([records[0]]);
297
- expect(result.entitiesAcrossPages).toEqual([records[0]]);
298
- expect(result.entityCount).toBe(1);
299
- });
300
- it("should filter with nested filters in _and and _or properly ", () => {
301
- const result = filterLocalEntitiesToHasura(
302
- [
303
- {
304
- id: 1,
305
- type: {
306
- special: "01"
307
- }
308
- },
309
- {
310
- id: 2,
311
- type: {
312
- special: "02"
313
- }
314
- }
315
- ],
316
- {
317
- where: {
318
- _and: [
319
- {
320
- type: {
321
- special: {
322
- _ilike: "%01%"
323
- }
324
- }
325
- }
326
- ],
327
- _or: []
328
- }
329
- }
330
- );
331
- expect(result.entities).toEqual([
332
- {
333
- id: 1,
334
- type: {
335
- special: "01"
336
- }
337
- }
338
- ]);
339
- expect(result.entitiesAcrossPages).toEqual([
340
- {
341
- id: 1,
342
- type: {
343
- special: "01"
344
- }
345
- }
346
- ]);
347
- expect(result.entityCount).toBe(1);
348
- });
349
-
350
- it("should handle empty where clause", () => {
351
- const result = filterLocalEntitiesToHasura(records, {});
352
- expect(result.entities).toEqual(records);
353
- expect(result.entitiesAcrossPages).toEqual(records);
354
- expect(result.entityCount).toBe(4);
355
- });
356
- it("should handle empty _and and _or clauses", () => {
357
- const result = filterLocalEntitiesToHasura(records, {
358
- where: { _and: [], _or: [] }
359
- });
360
- expect(result.entities).toEqual(records);
361
- expect(result.entitiesAcrossPages).toEqual(records);
362
- expect(result.entityCount).toBe(4);
363
- });
364
-
365
- it("should handle nested _and and _or", () => {
366
- const result = filterLocalEntitiesToHasura(records, {
367
- where: {
368
- _and: [
369
- { _or: [{ city: { _eq: "London" } }, { city: { _eq: "Paris" } }] },
370
- { age: { _gt: 20 } }
371
- ]
372
- }
373
- });
374
- expect(result.entities).toEqual([records[0], records[1], records[2]]);
375
- expect(result.entitiesAcrossPages).toEqual([
376
- records[0],
377
- records[1],
378
- records[2]
379
- ]);
380
- expect(result.entityCount).toBe(3);
381
- });
382
- it("should order by age ascending", () => {
383
- const result = filterLocalEntitiesToHasura(records, {
384
- order_by: { age: "asc" }
385
- });
386
- expect(result.entities).toEqual([
387
- records[3],
388
- records[1],
389
- records[0],
390
- records[2]
391
- ]);
392
- expect(result.entitiesAcrossPages).toEqual([
393
- records[3],
394
- records[1],
395
- records[0],
396
- records[2]
397
- ]);
398
- expect(result.entityCount).toBe(4);
399
- });
400
-
401
- it("should order by age descending", () => {
402
- const result = filterLocalEntitiesToHasura(records, {
403
- order_by: { age: "desc" }
404
- });
405
- expect(result.entities).toEqual([
406
- records[2],
407
- records[0],
408
- records[1],
409
- records[3]
410
- ]);
411
- expect(result.entitiesAcrossPages).toEqual([
412
- records[2],
413
- records[0],
414
- records[1],
415
- records[3]
416
- ]);
417
- expect(result.entityCount).toBe(4);
418
- });
419
-
420
- it("should order by name ascending", () => {
421
- const result = filterLocalEntitiesToHasura(records, {
422
- order_by: { name: "asc" }
423
- });
424
- expect(result.entities).toEqual([
425
- records[2],
426
- records[3],
427
- records[1],
428
- records[0]
429
- ]);
430
- expect(result.entitiesAcrossPages).toEqual([
431
- records[2],
432
- records[3],
433
- records[1],
434
- records[0]
435
- ]);
436
- expect(result.entityCount).toBe(4);
437
- });
438
-
439
- it("should order by name descending", () => {
440
- const result = filterLocalEntitiesToHasura(records, {
441
- order_by: { name: "desc" }
442
- });
443
- expect(result.entities).toEqual([
444
- records[0],
445
- records[1],
446
- records[3],
447
- records[2]
448
- ]);
449
- expect(result.entitiesAcrossPages).toEqual([
450
- records[0],
451
- records[1],
452
- records[3],
453
- records[2]
454
- ]);
455
- expect(result.entityCount).toBe(4);
456
- });
457
-
458
- it("should filter and order", () => {
459
- const result = filterLocalEntitiesToHasura(records, {
460
- where: { city: { _eq: "London" } },
461
- order_by: { age: "desc" }
462
- });
463
- expect(result.entities).toEqual([records[2], records[0]]);
464
- expect(result.entitiesAcrossPages).toEqual([records[2], records[0]]);
465
- expect(result.entityCount).toBe(2);
466
- });
467
-
468
- it("should handle empty order_by", () => {
469
- const result = filterLocalEntitiesToHasura(records, {
470
- where: { city: { _eq: "London" } }
471
- });
472
- expect(result.entities).toEqual([records[0], records[2]]);
473
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
474
- expect(result.entityCount).toBe(2);
475
- });
476
-
477
- it("should handle order_by with empty where", () => {
478
- const result = filterLocalEntitiesToHasura(records, {
479
- order_by: { age: "asc" }
480
- });
481
- expect(result.entities).toEqual([
482
- records[3],
483
- records[1],
484
- records[0],
485
- records[2]
486
- ]);
487
- expect(result.entitiesAcrossPages).toEqual([
488
- records[3],
489
- records[1],
490
- records[0],
491
- records[2]
492
- ]);
493
- expect(result.entityCount).toBe(4);
494
- });
495
-
496
- it("should apply limit", () => {
497
- const result = filterLocalEntitiesToHasura(records, { limit: 2 });
498
- expect(result.entities).toEqual([records[0], records[1]]);
499
- expect(result.entitiesAcrossPages).toEqual(records);
500
- expect(result.entityCount).toBe(4);
501
- });
502
-
503
- it("should apply offset", () => {
504
- const result = filterLocalEntitiesToHasura(records, { offset: 2 });
505
- expect(result.entities).toEqual([records[2], records[3]]);
506
- expect(result.entitiesAcrossPages).toEqual(records);
507
- expect(result.entityCount).toBe(4);
508
- });
509
-
510
- it("should apply limit and offset", () => {
511
- const result = filterLocalEntitiesToHasura(records, {
512
- limit: 1,
513
- offset: 2
514
- });
515
- expect(result.entities).toEqual([records[2]]);
516
- expect(result.entitiesAcrossPages).toEqual(records);
517
- expect(result.entityCount).toBe(4);
518
- });
519
-
520
- it("should apply limit to filtered results", () => {
521
- const result = filterLocalEntitiesToHasura(records, {
522
- where: { city: { _eq: "London" } },
523
- limit: 1
524
- });
525
- expect(result.entities).toEqual([records[0]]);
526
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
527
- expect(result.entityCount).toBe(2);
528
- });
529
-
530
- it("should apply offset to filtered results", () => {
531
- const result = filterLocalEntitiesToHasura(records, {
532
- where: { city: { _eq: "London" } },
533
- offset: 1
534
- });
535
- expect(result.entities).toEqual([records[2]]);
536
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
537
- expect(result.entityCount).toBe(2);
538
- });
539
-
540
- it("should apply limit and offset to filtered and ordered results", () => {
541
- const result = filterLocalEntitiesToHasura(records, {
542
- where: { city: { _eq: "London" } },
543
- order_by: { age: "desc" },
544
- limit: 1,
545
- offset: 1
546
- });
547
- expect(result.entities).toEqual([records[0]]);
548
- expect(result.entitiesAcrossPages).toEqual([records[2], records[0]]);
549
- expect(result.entityCount).toBe(2);
550
- });
551
-
552
- it("should handle offset greater than array length", () => {
553
- const result = filterLocalEntitiesToHasura(records, { offset: 10 });
554
- expect(result.entities).toEqual([]);
555
- expect(result.entitiesAcrossPages).toEqual(records);
556
- expect(result.entityCount).toBe(4);
557
- });
558
-
559
- it("should handle limit greater than array length", () => {
560
- const result = filterLocalEntitiesToHasura(records, { limit: 10 });
561
- expect(result.entities).toEqual(records);
562
- expect(result.entitiesAcrossPages).toEqual(records);
563
- expect(result.entityCount).toBe(4);
564
- });
565
-
566
- it("should handle isInfinite option with filtering", () => {
567
- const result = filterLocalEntitiesToHasura(records, {
568
- where: { city: { _eq: "London" } },
569
- isInfinite: true
570
- });
571
- expect(result.entities).toEqual([records[0], records[2]]);
572
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
573
- expect(result.entityCount).toBe(2);
574
- });
575
-
576
- it("should handle isInfinite option with filtering, limit, and offset", () => {
577
- const result = filterLocalEntitiesToHasura(records, {
578
- where: { city: { _eq: "London" } },
579
- limit: 1,
580
- offset: 1,
581
- isInfinite: true
582
- });
583
- expect(result.entities).toEqual([records[0], records[2]]);
584
- expect(result.entitiesAcrossPages).toEqual([records[0], records[2]]);
585
- expect(result.entityCount).toBe(2);
586
- });
587
- });
@@ -1,16 +0,0 @@
1
- import { getFieldPathToField } from "./getFieldPathToField";
2
-
3
- export const formatPasteData = ({ schema, newVal, path }) => {
4
- const pathToField = getFieldPathToField(schema);
5
- const column = pathToField[path];
6
- if (column.type === "genericSelect") {
7
- if (newVal?.__genSelCol === path) {
8
- newVal = newVal.__strVal;
9
- } else {
10
- newVal = undefined;
11
- }
12
- } else {
13
- newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
14
- }
15
- return newVal;
16
- };
@@ -1,11 +0,0 @@
1
- export const getAllRows = e => {
2
- const el = e.target.querySelector(".data-table-container")
3
- ? e.target.querySelector(".data-table-container")
4
- : e.target.closest(".data-table-container");
5
-
6
- const allRowEls = el.querySelectorAll(".rt-tr");
7
- if (!allRowEls || !allRowEls.length) {
8
- return;
9
- }
10
- return allRowEls;
11
- };
@@ -1,7 +0,0 @@
1
- export const getCellCopyText = cellWrapper => {
2
- const text = cellWrapper && cellWrapper.getAttribute("data-copy-text");
3
- const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
4
-
5
- const textContent = text || cellWrapper.textContent || "";
6
- return [textContent, jsonText];
7
- };
@@ -1,36 +0,0 @@
1
- import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
2
-
3
- export const getCellInfo = ({
4
- columnIndex,
5
- columnPath,
6
- rowId,
7
- schema,
8
- entities,
9
- rowIndex,
10
- isEntityDisabled,
11
- entity
12
- }) => {
13
- const leftpath = schema.fields[columnIndex - 1]?.path;
14
- const rightpath = schema.fields[columnIndex + 1]?.path;
15
- const cellIdToLeft = leftpath && `${rowId}:${leftpath}`;
16
- const cellIdToRight = rightpath && `${rowId}:${rightpath}`;
17
- const rowAboveId =
18
- entities[rowIndex - 1] &&
19
- getIdOrCodeOrIndex(entities[rowIndex - 1], rowIndex - 1);
20
- const rowBelowId =
21
- entities[rowIndex + 1] &&
22
- getIdOrCodeOrIndex(entities[rowIndex + 1], rowIndex + 1);
23
- const cellIdAbove = rowAboveId && `${rowAboveId}:${columnPath}`;
24
- const cellIdBelow = rowBelowId && `${rowBelowId}:${columnPath}`;
25
-
26
- const cellId = `${rowId}:${columnPath}`;
27
- const rowDisabled = isEntityDisabled(entity);
28
- return {
29
- cellId,
30
- cellIdAbove,
31
- cellIdToRight,
32
- cellIdBelow,
33
- cellIdToLeft,
34
- rowDisabled
35
- };
36
- };
@@ -1,7 +0,0 @@
1
- export const getFieldPathToField = schema => {
2
- const fieldPathToField = {};
3
- schema.fields.forEach(f => {
4
- fieldPathToField[f.path] = f;
5
- });
6
- return fieldPathToField;
7
- };
@@ -1,9 +0,0 @@
1
- export const getIdOrCodeOrIndex = (record, rowIndex) => {
2
- if (record.id || record.id === 0) {
3
- return record.id;
4
- } else if (record.code) {
5
- return record.code;
6
- } else {
7
- return rowIndex;
8
- }
9
- };
@@ -1,11 +0,0 @@
1
- export const getLastSelectedEntity = idMap => {
2
- let lastSelectedEnt;
3
- let latestTime;
4
- Object.values(idMap).forEach(({ time, entity }) => {
5
- if (!latestTime || time > latestTime) {
6
- lastSelectedEnt = entity;
7
- latestTime = time;
8
- }
9
- });
10
- return lastSelectedEnt;
11
- };