@teselagen/ui 0.7.33-beta.3 → 0.7.33-beta.5

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 (142) hide show
  1. package/DataTable/utils/queryParams.d.ts +3 -8
  2. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +12 -0
  3. package/index.cjs.js +161 -27
  4. package/index.es.js +161 -27
  5. package/package.json +1 -1
  6. package/src/AdvancedOptions.spec.js +26 -0
  7. package/src/AsyncValidateFieldSpinner/index.js +12 -0
  8. package/src/BlueprintError/index.js +14 -0
  9. package/src/BounceLoader/index.js +16 -0
  10. package/src/BounceLoader/style.css +45 -0
  11. package/src/CollapsibleCard/index.js +68 -0
  12. package/src/CollapsibleCard/style.css +23 -0
  13. package/src/DNALoader/index.js +20 -0
  14. package/src/DNALoader/style.css +251 -0
  15. package/src/{Columns.js → DataTable/Columns.js} +1 -1
  16. package/src/{DisplayOptions.js → DataTable/DisplayOptions.js} +1 -1
  17. package/src/DataTable/index.js +3209 -0
  18. package/src/DataTable/style.css +608 -0
  19. package/src/{filterLocalEntitiesToHasura.js → DataTable/utils/filterLocalEntitiesToHasura.js} +6 -0
  20. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +538 -0
  21. package/src/DataTable/utils/index.js +55 -0
  22. package/src/{initializeHasuraWhereAndFilter.js → DataTable/utils/initializeHasuraWhereAndFilter.js} +0 -1
  23. package/src/{queryParams.js → DataTable/utils/queryParams.js} +32 -21
  24. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +250 -0
  25. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +206 -0
  26. package/src/{withTableParams.js → DataTable/utils/withTableParams.js} +2 -2
  27. package/src/DialogFooter/index.js +86 -0
  28. package/src/DialogFooter/style.css +9 -0
  29. package/src/FormComponents/index.js +1266 -0
  30. package/src/FormComponents/style.css +275 -0
  31. package/src/FormComponents/utils.js +6 -0
  32. package/src/HotkeysDialog/index.js +79 -0
  33. package/src/HotkeysDialog/style.css +54 -0
  34. package/src/InfoHelper/index.js +78 -0
  35. package/src/InfoHelper/style.css +7 -0
  36. package/src/IntentText/index.js +18 -0
  37. package/src/Loading/index.js +70 -0
  38. package/src/Loading/style.css +4 -0
  39. package/src/MenuBar/index.js +423 -0
  40. package/src/MenuBar/style.css +45 -0
  41. package/src/PromptUnsavedChanges/index.js +38 -0
  42. package/src/ResizableDraggableDialog/index.js +141 -0
  43. package/src/ResizableDraggableDialog/style.css +42 -0
  44. package/src/ScrollToTop/index.js +72 -0
  45. package/src/TagSelect/index.js +69 -0
  46. package/src/TagSelect/style.css +13 -0
  47. package/src/TgHtmlSelect/index.js +20 -0
  48. package/src/TgSelect/index.js +537 -0
  49. package/src/TgSelect/style.css +61 -0
  50. package/src/TgSuggest/index.js +124 -0
  51. package/src/Timeline/index.js +15 -0
  52. package/src/Timeline/style.css +29 -0
  53. package/src/enhancers/withDialog/index.js +196 -0
  54. package/src/index.js +88 -1
  55. package/src/showConfirmationDialog/index.js +148 -0
  56. package/src/style.css +261 -9
  57. package/src/utils/hooks/index.js +1 -0
  58. package/DataTable/utils/simplifyHasuraWhere.d.ts +0 -1
  59. package/src/simplifyHasuraWhere.js +0 -80
  60. package/src/tableQueryParamsToHasuraClauses.js +0 -113
  61. /package/src/{CellDragHandle.js → DataTable/CellDragHandle.js} +0 -0
  62. /package/src/{ColumnFilterMenu.js → DataTable/ColumnFilterMenu.js} +0 -0
  63. /package/src/{DisabledLoadingComponent.js → DataTable/DisabledLoadingComponent.js} +0 -0
  64. /package/src/{DropdownCell.js → DataTable/DropdownCell.js} +0 -0
  65. /package/src/{EditableCell.js → DataTable/EditableCell.js} +0 -0
  66. /package/src/{FilterAndSortMenu.js → DataTable/FilterAndSortMenu.js} +0 -0
  67. /package/src/{PagingTool.js → DataTable/PagingTool.js} +0 -0
  68. /package/src/{RenderCell.js → DataTable/RenderCell.js} +0 -0
  69. /package/src/{SearchBar.js → DataTable/SearchBar.js} +0 -0
  70. /package/src/{SortableColumns.js → DataTable/SortableColumns.js} +0 -0
  71. /package/src/{TableFormTrackerContext.js → DataTable/TableFormTrackerContext.js} +0 -0
  72. /package/src/{ThComponent.js → DataTable/ThComponent.js} +0 -0
  73. /package/src/{dataTableEnhancer.js → DataTable/dataTableEnhancer.js} +0 -0
  74. /package/src/{defaultFormatters.js → DataTable/defaultFormatters.js} +0 -0
  75. /package/src/{defaultValidators.js → DataTable/defaultValidators.js} +0 -0
  76. /package/src/{editCellHelper.js → DataTable/editCellHelper.js} +0 -0
  77. /package/src/{getCellVal.js → DataTable/getCellVal.js} +0 -0
  78. /package/src/{getVals.js → DataTable/getVals.js} +0 -0
  79. /package/src/{isTruthy.js → DataTable/isTruthy.js} +0 -0
  80. /package/src/{isValueEmpty.js → DataTable/isValueEmpty.js} +0 -0
  81. /package/src/{convertSchema.js → DataTable/utils/convertSchema.js} +0 -0
  82. /package/src/{formatPasteData.js → DataTable/utils/formatPasteData.js} +0 -0
  83. /package/src/{getAllRows.js → DataTable/utils/getAllRows.js} +0 -0
  84. /package/src/{getCellCopyText.js → DataTable/utils/getCellCopyText.js} +0 -0
  85. /package/src/{getCellInfo.js → DataTable/utils/getCellInfo.js} +0 -0
  86. /package/src/{getFieldPathToField.js → DataTable/utils/getFieldPathToField.js} +0 -0
  87. /package/src/{getIdOrCodeOrIndex.js → DataTable/utils/getIdOrCodeOrIndex.js} +0 -0
  88. /package/src/{getLastSelectedEntity.js → DataTable/utils/getLastSelectedEntity.js} +0 -0
  89. /package/src/{getNewEntToSelect.js → DataTable/utils/getNewEntToSelect.js} +0 -0
  90. /package/src/{getRowCopyText.js → DataTable/utils/getRowCopyText.js} +0 -0
  91. /package/src/{getTableConfigFromStorage.js → DataTable/utils/getTableConfigFromStorage.js} +0 -0
  92. /package/src/{handleCopyColumn.js → DataTable/utils/handleCopyColumn.js} +0 -0
  93. /package/src/{handleCopyHelper.js → DataTable/utils/handleCopyHelper.js} +0 -0
  94. /package/src/{handleCopyRows.js → DataTable/utils/handleCopyRows.js} +0 -0
  95. /package/src/{handleCopyTable.js → DataTable/utils/handleCopyTable.js} +0 -0
  96. /package/src/{isBottomRightCornerOfRectangle.js → DataTable/utils/isBottomRightCornerOfRectangle.js} +0 -0
  97. /package/src/{isEntityClean.js → DataTable/utils/isEntityClean.js} +0 -0
  98. /package/src/{primarySelectedValue.js → DataTable/utils/primarySelectedValue.js} +0 -0
  99. /package/src/{removeCleanRows.js → DataTable/utils/removeCleanRows.js} +0 -0
  100. /package/src/{rowClick.js → DataTable/utils/rowClick.js} +0 -0
  101. /package/src/{selection.js → DataTable/utils/selection.js} +0 -0
  102. /package/src/{useTableEntities.js → DataTable/utils/useTableEntities.js} +0 -0
  103. /package/src/{utils.js → DataTable/utils/utils.js} +0 -0
  104. /package/src/{withSelectedEntities.js → DataTable/utils/withSelectedEntities.js} +0 -0
  105. /package/src/{validateTableWideErrors.js → DataTable/validateTableWideErrors.js} +0 -0
  106. /package/src/{viewColumn.js → DataTable/viewColumn.js} +0 -0
  107. /package/src/{FormSeparator.js → FormComponents/FormSeparator.js} +0 -0
  108. /package/src/{LoadingDots.js → FormComponents/LoadingDots.js} +0 -0
  109. /package/src/{Uploader.js → FormComponents/Uploader.js} +0 -0
  110. /package/src/{getNewName.js → FormComponents/getNewName.js} +0 -0
  111. /package/src/{itemUpload.js → FormComponents/itemUpload.js} +0 -0
  112. /package/src/{sortify.js → FormComponents/sortify.js} +0 -0
  113. /package/src/{tryToMatchSchemas.js → FormComponents/tryToMatchSchemas.js} +0 -0
  114. /package/src/{TimelineEvent.js → Timeline/TimelineEvent.js} +0 -0
  115. /package/src/{tg_modalState.js → enhancers/withDialog/tg_modalState.js} +0 -0
  116. /package/src/{withField.js → enhancers/withField.js} +0 -0
  117. /package/src/{withFields.js → enhancers/withFields.js} +0 -0
  118. /package/src/{withLocalStorage.js → enhancers/withLocalStorage.js} +0 -0
  119. /package/src/{adHoc.js → utils/adHoc.js} +0 -0
  120. /package/src/{basicHandleActionsWithFullState.js → utils/basicHandleActionsWithFullState.js} +0 -0
  121. /package/src/{browserUtils.js → utils/browserUtils.js} +0 -0
  122. /package/src/{combineReducersWithFullState.js → utils/combineReducersWithFullState.js} +0 -0
  123. /package/src/{commandControls.js → utils/commandControls.js} +0 -0
  124. /package/src/{commandUtils.js → utils/commandUtils.js} +0 -0
  125. /package/src/{determineBlackOrWhiteTextColor.js → utils/determineBlackOrWhiteTextColor.js} +0 -0
  126. /package/src/{getDayjsFormatter.js → utils/getDayjsFormatter.js} +0 -0
  127. /package/src/{getTextFromEl.js → utils/getTextFromEl.js} +0 -0
  128. /package/src/{handlerHelpers.js → utils/handlerHelpers.js} +0 -0
  129. /package/src/{useDeepEqualMemo.js → utils/hooks/useDeepEqualMemo.js} +0 -0
  130. /package/src/{useStableReference.js → utils/hooks/useStableReference.js} +0 -0
  131. /package/src/{hotkeyUtils.js → utils/hotkeyUtils.js} +0 -0
  132. /package/src/{isBeingCalledExcessively.js → utils/isBeingCalledExcessively.js} +0 -0
  133. /package/src/{menuUtils.js → utils/menuUtils.js} +0 -0
  134. /package/src/{popoverOverflowModifiers.js → utils/popoverOverflowModifiers.js} +0 -0
  135. /package/src/{pureNoFunc.js → utils/pureNoFunc.js} +0 -0
  136. /package/src/{renderOnDoc.js → utils/renderOnDoc.js} +0 -0
  137. /package/src/{showProgressToast.js → utils/showProgressToast.js} +0 -0
  138. /package/src/{tagUtils.js → utils/tagUtils.js} +0 -0
  139. /package/src/{tgFormValues.js → utils/tgFormValues.js} +0 -0
  140. /package/src/{useTraceUpdate.js → utils/useTraceUpdate.js} +0 -0
  141. /package/src/{withSelectTableRecords.js → utils/withSelectTableRecords.js} +0 -0
  142. /package/src/{withStore.js → utils/withStore.js} +0 -0
package/src/style.css CHANGED
@@ -1,13 +1,265 @@
1
- .tag-select-popover {
2
- padding: 10px;
1
+ :root {
2
+ --base1: #ffffff;
3
+ --base2: #cdcdcd;
3
4
  }
4
5
 
5
- .tag-select-popover-inner {
6
- max-height: 150px;
6
+ body.bp3-dark {
7
+ --base1: #393a3a;
8
+ --base2: #293742;
9
+ }
10
+
11
+ .bp3-dark .tg-card {
12
+ background: #394b59 !important;
13
+ }
14
+
15
+ .preserve-newline {
16
+ white-space: pre-line;
17
+ }
18
+
19
+ .bp3-dialog {
20
+ max-width: 100vw;
21
+ }
22
+
23
+ /* adding back in blueprint v2 default styling to all <h/> elements */
24
+ h1 {
25
+ line-height: 40px;
26
+ font-size: 36px;
27
+ }
28
+
29
+ h2 {
30
+ line-height: 32px;
31
+ font-size: 28px;
32
+ }
33
+
34
+ h3 {
35
+ line-height: 25px;
36
+ font-size: 22px;
37
+ }
38
+
39
+ h4 {
40
+ line-height: 21px;
41
+ font-size: 18px;
42
+ }
43
+
44
+ h5 {
45
+ line-height: 19px;
46
+ font-size: 16px;
47
+ }
48
+
49
+ h6 {
50
+ line-height: 16px;
51
+ font-size: 14px;
52
+ }
53
+
54
+ h1,
55
+ h2,
56
+ h3,
57
+ h4,
58
+ h5,
59
+ h6,
60
+ h1.bp3-heading,
61
+ h2.bp3-heading,
62
+ h3.bp3-heading,
63
+ h4.bp3-heading,
64
+ h5.bp3-heading,
65
+ h6.bp3-heading {
66
+ color: #182026;
67
+ font-weight: 300;
68
+ margin: 0 0 10px;
69
+ padding: 0;
70
+ line-height: normal;
71
+ }
72
+
73
+ .bp3-dark h1,
74
+ .bp3-dark h2,
75
+ .bp3-dark h3,
76
+ .bp3-dark h4,
77
+ .bp3-dark h5,
78
+ .bp3-dark h6 {
79
+ color: #f5f8fa;
80
+ }
81
+ .bp3-dark textarea {
82
+ background: #293742;
83
+ color: #f5f8fa;
84
+ }
85
+
86
+ /* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
87
+ .bp3-popover-wrapper {
88
+ display: inline-block;
89
+ position: relative;
90
+ vertical-align: top;
91
+ }
92
+ /* this line is necessary otherwise the line above setting "position: relative;" caused nested long bp3 submenus to not appear correctly when using the fix below */
93
+ .bp3-submenu .bp3-popover-wrapper {
94
+ position: unset;
95
+ }
96
+ /* this fixes https://github.com/palantir/blueprint/issues/4791 but requires the "position: unset;" fix above */
97
+ .bp3-submenu > * > .bp3-menu {
98
+ max-height: 96vh;
7
99
  overflow: auto;
8
- display: grid;
9
- padding-top: 10px;
10
- grid-column-gap: 5px;
11
- row-gap: 8px;
12
- grid-template-columns: max-content max-content;
100
+ }
101
+
102
+ /* bp3 fix https://github.com/palantir/blueprint/issues/2807 */
103
+ span.bp3-popover-target {
104
+ display: block;
105
+ }
106
+
107
+ .bp3-portal {
108
+ z-index: 100000;
109
+ }
110
+ .bp3-switch {
111
+ width: fit-content;
112
+ display: flex;
113
+ align-items: center;
114
+ }
115
+
116
+ .Select {
117
+ min-width: 170px;
118
+ }
119
+
120
+ /* override the default blueprint input focus to instead rely on an inset box shadow. This resolves any issues with overflow:hidden cutting off input box shadows */
121
+ .bp3-dark .bp3-input:focus,
122
+ .bp3-input:focus {
123
+ box-shadow: inset 0 0 3px 1px #137cbd;
124
+ }
125
+
126
+ .notClickable {
127
+ cursor: default !important;
128
+ }
129
+ .bp3-toast-container {
130
+ z-index: 100001;
131
+ }
132
+
133
+ .link-button {
134
+ background: none !important;
135
+ border: none;
136
+ padding: 0 !important;
137
+ font-family: arial, sans-serif;
138
+ color: rgb(0, 151, 227);
139
+ /* text-decoration: underline; */
140
+ cursor: pointer;
141
+ }
142
+ .link-button:hover {
143
+ color: rgb(98, 198, 248);
144
+ text-decoration: underline;
145
+ }
146
+
147
+ .above-dialog {
148
+ z-index: 100001;
149
+ }
150
+
151
+ code {
152
+ display: block;
153
+ white-space: pre-wrap;
154
+ }
155
+
156
+ .bp3-toast.no-close-button [aria-label="Close"] {
157
+ display: none;
158
+ }
159
+
160
+ .isDataTitle .tippy-box[data-theme~="teselagen"] .tippy-arrow {
161
+ opacity: 0 !important;
162
+ }
163
+ .isDataTitle .tippy-box[data-theme~="teselagen"] {
164
+ background-color: #4f4a50f4 !important;
165
+ border-radius: 0 !important;
166
+ color: #f3f3f3 !important;
167
+ font-size: 11px !important;
168
+ white-space: pre-wrap;
169
+ padding: 0px 0px !important;
170
+ }
171
+
172
+ [data-tippy-root]:has(.tippy-box[data-theme~="teselagen"]) {
173
+ z-index: 100000 !important;
174
+ }
175
+
176
+ [data-tippy-root] .tippy-box[data-theme~="teselagen"] {
177
+ background-color: #394b59;
178
+ color: #f5f8fa;
179
+ padding: 4px 4px;
180
+ word-break: break-word;
181
+ }
182
+ [data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
183
+ color: #394b59;
184
+ }
185
+ .bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] {
186
+ background-color: #e1e8ed;
187
+ color: #394b59;
188
+ }
189
+ .bp3-dark [data-tippy-root] .tippy-box[data-theme~="teselagen"] .tippy-arrow {
190
+ /* background-color: #e1e8ed; */
191
+ color: #e1e8ed;
192
+ }
193
+ .isCellEditable .rt-td {
194
+ position: relative;
195
+ }
196
+
197
+ .ReactTable .tg-cell-edit-boolean-checkbox {
198
+ margin-bottom: 0;
199
+ }
200
+
201
+ .cellDragHandle {
202
+ height: 8px;
203
+ width: 8px;
204
+ cursor: crosshair;
205
+ border: 1px solid rgb(255, 255, 255);
206
+ background-color: rgb(76, 107, 171);
207
+ position: absolute;
208
+ bottom: -4px;
209
+ right: -4px;
210
+ }
211
+
212
+ /* make AnchorButton match Button */
213
+ .bp3-button {
214
+ font-family: Arial;
215
+ }
216
+
217
+ button {
218
+ transition: all 0.2s ease-in-out;
219
+ }
220
+
221
+ button:not(:disabled):active {
222
+ transform: translateY(1px);
223
+ }
224
+ .bp3-tabs.bp3-vertical > .bp3-tab-panel {
225
+ min-width: 0px;
226
+ }
227
+ .bp3-toast[class*="bp3-intent-"] .bp3-button.tg-clear-all-toasts {
228
+ border: 1px solid white !important;
229
+ }
230
+ .bp3-toast[class*="bp3-intent-"] .bp3-button.tg-clear-all-toasts:hover {
231
+ /* background: blue !important; */
232
+ /* background: unset !important; */
233
+ background-color: #137cbd !important;
234
+ }
235
+
236
+ /* .bp3-toast .tg-clear-all-toasts {
237
+ background: unset !important;
238
+ color: unset !important;
239
+ padding: unset !important;
240
+ margin: unset !important;
241
+ font-size: unset !important;
242
+ line-height: unset !important;
243
+ border: unset !important;
244
+ box-shadow: unset !important;
245
+ text-align: unset !important;
246
+ cursor: pointer !important;
247
+ } */
248
+
249
+ .bp3-dialog-header .bp3-heading {
250
+ width: 10px; /* tnw: this is a hack to prevent the dialog title from causing the dialog width to expand larger than the dialog content*/
251
+ }
252
+
253
+ /* to fix tooltip styling issue - https://github.com/palantir/blueprint/issues/3430 */
254
+ .bp3-popover[style*="transform-origin"][style*="bottom"] .bp3-popover-arrow {
255
+ transform: translate(0, -0.5px);
256
+ }
257
+ .bp3-popover[style*="transform-origin"][style*="left"] .bp3-popover-arrow {
258
+ transform: translate(0.5px, 0);
259
+ }
260
+ .bp3-popover[style*="transform-origin"][style*="top"] .bp3-popover-arrow {
261
+ transform: translate(0, 0.5px);
262
+ }
263
+ .bp3-popover[style*="transform-origin"][style*="right"] .bp3-popover-arrow {
264
+ transform: translate(-0.5px, 0);
13
265
  }
@@ -0,0 +1 @@
1
+ export { useDeepEqualMemo } from "./useDeepEqualMemo";
@@ -1 +0,0 @@
1
- export function simplifyHasuraWhere(whereClause: any): {};
@@ -1,80 +0,0 @@
1
- export function simplifyHasuraWhere(whereClause) {
2
- const simplifiedWhere = {};
3
-
4
- for (const key in whereClause) {
5
- // eslint-disable-next-line no-prototype-builtins
6
- if (whereClause.hasOwnProperty(key)) {
7
- const value = whereClause[key];
8
-
9
- if (
10
- typeof value === "object" &&
11
- value !== null &&
12
- !Array.isArray(value)
13
- ) {
14
- if (key.includes(".")) {
15
- // Handle dot-nested where clauses
16
- const keys = key.split(".");
17
- let currentObj = simplifiedWhere;
18
- for (let i = 0; i < keys.length - 1; i++) {
19
- const nestedKey = keys[i];
20
- if (!currentObj[nestedKey]) {
21
- currentObj[nestedKey] = {};
22
- }
23
- currentObj = currentObj[nestedKey];
24
- }
25
- if (typeof value === "object" && value !== null && "_eq" in value) {
26
- currentObj[keys[keys.length - 1]] = value;
27
- } else {
28
- currentObj[keys[keys.length - 1]] = { _eq: value };
29
- }
30
- } else {
31
- // Handle regular Hasura operators or already nested objects.
32
- if (
33
- typeof value === "object" &&
34
- value !== null &&
35
- !("_eq" in value) &&
36
- !("_gt" in value) &&
37
- !("_lt" in value) &&
38
- !("_gte" in value) &&
39
- !("_lte" in value) &&
40
- !("_in" in value) &&
41
- !("_nin" in value) &&
42
- !("_neq" in value) &&
43
- !("_like" in value) &&
44
- !("_nlike" in value) &&
45
- !("_ilike" in value) &&
46
- !("_nilike" in value) &&
47
- !("_similar" in value) &&
48
- !("_nsimilar" in value) &&
49
- !("_regex" in value) &&
50
- !("_nregex" in value) &&
51
- !("_iregex" in value) &&
52
- !("_niregex" in value)
53
- ) {
54
- simplifiedWhere[key] = simplifyHasuraWhere(value);
55
- } else {
56
- simplifiedWhere[key] = value;
57
- }
58
- }
59
- } else {
60
- // Handle simplified _eq where clauses
61
- if (key.includes(".")) {
62
- const keys = key.split(".");
63
- let currentObj = simplifiedWhere;
64
- for (let i = 0; i < keys.length - 1; i++) {
65
- const nestedKey = keys[i];
66
- if (!currentObj[nestedKey]) {
67
- currentObj[nestedKey] = {};
68
- }
69
- currentObj = currentObj[nestedKey];
70
- }
71
- currentObj[keys[keys.length - 1]] = { _eq: value };
72
- } else {
73
- simplifiedWhere[key] = { _eq: value };
74
- }
75
- }
76
- }
77
- }
78
-
79
- return simplifiedWhere;
80
- }
@@ -1,113 +0,0 @@
1
- export function tableQueryParamsToHasuraClauses({
2
- page,
3
- pageSize,
4
- searchTerm,
5
- filters,
6
- order,
7
- schema, // Add schema as a parameter
8
- additionalFilter
9
- }) {
10
- let where = {};
11
- const order_by = {};
12
- const limit = pageSize || 25;
13
- const offset = page && pageSize ? (page - 1) * pageSize : 0;
14
-
15
- if (searchTerm) {
16
- const searchTermFilters = [];
17
- schema.fields.forEach(field => {
18
- const { type, path, searchDisabled } = field;
19
- if (searchDisabled || field.filterDisabled || type === "color") return;
20
- const filterValue = searchTerm; // No cleaning needed here, we're using _ilike
21
-
22
- if (type === "string" || type === "lookup") {
23
- searchTermFilters.push({
24
- [path]: { _ilike: `%${filterValue}%` }
25
- });
26
- } else if (type === "boolean") {
27
- let regex;
28
- try {
29
- regex = new RegExp("^" + searchTerm, "ig");
30
- } catch (error) {
31
- //ignore
32
- }
33
- if (regex) {
34
- if ("true".replace(regex, "") !== "true") {
35
- searchTermFilters.push({
36
- [path]: { _eq: true }
37
- });
38
- } else if ("false".replace(regex, "") !== "false") {
39
- searchTermFilters.push({
40
- [path]: { _eq: false }
41
- });
42
- }
43
- }
44
- } else if (
45
- (type === "number" || type === "integer") &&
46
- !isNaN(filterValue)
47
- ) {
48
- searchTermFilters.push({
49
- [path]: { _eq: parseFloat(filterValue) }
50
- });
51
- }
52
- });
53
- if (searchTermFilters.length > 0) {
54
- if (Object.keys(where).length > 0) {
55
- where = { _and: [where, { _or: searchTermFilters }] };
56
- } else {
57
- where = { _or: searchTermFilters };
58
- }
59
- }
60
- }
61
-
62
- if (filters && filters.length > 0) {
63
- const filterClauses = filters.map(filter => {
64
- const { selectedFilter, filterOn, filterValue } = filter;
65
- switch (selectedFilter) {
66
- case "textContains":
67
- return { [filterOn]: { _ilike: `%${filterValue}%` } };
68
- case "textEquals":
69
- return { [filterOn]: { _eq: filterValue } };
70
- case "textNotEquals":
71
- return { [filterOn]: { _neq: filterValue } };
72
- case "numberEquals":
73
- return { [filterOn]: { _eq: parseFloat(filterValue) } };
74
- case "numberGreaterThan":
75
- return { [filterOn]: { _gt: parseFloat(filterValue) } };
76
- case "numberLessThan":
77
- return { [filterOn]: { _lt: parseFloat(filterValue) } };
78
- case "numberGreaterThanEquals":
79
- return { [filterOn]: { _gte: parseFloat(filterValue) } };
80
- case "numberLessThanEquals":
81
- return { [filterOn]: { _lte: parseFloat(filterValue) } };
82
- case "isNull":
83
- return { [filterOn]: { _is_null: true } };
84
- case "isNotNull":
85
- return { [filterOn]: { _is_null: false } };
86
- default:
87
- console.warn(`Unsupported filter type: ${selectedFilter}`);
88
- return {};
89
- }
90
- });
91
-
92
- if (filterClauses.length > 0) {
93
- if (Object.keys(where).length > 0) {
94
- where = { _and: [where, ...filterClauses] };
95
- } else {
96
- where = { _and: filterClauses };
97
- }
98
- }
99
- }
100
-
101
- if (order && order.length > 0) {
102
- order.forEach(item => {
103
- const field = item.startsWith("-") ? item.substring(1) : item;
104
- const direction = item.startsWith("-") ? "desc" : "asc";
105
- order_by[field] = direction;
106
- });
107
- }
108
-
109
- if (additionalFilter) {
110
- where = { _and: [where, additionalFilter] };
111
- }
112
- return { where, order_by, limit, offset };
113
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes