@teselagen/ui 0.10.5 → 0.10.6
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/DataTable/DisplayOptions.d.ts +2 -1
- package/DataTable/DraggableColumnOptions.d.ts +7 -0
- package/DataTable/SortableColumns.d.ts +2 -1
- package/DataTable/ThComponent.d.ts +2 -1
- package/DataTable/dragNoticeEl.d.ts +1 -0
- package/DataTable/viewColumn.d.ts +0 -2
- package/index.cjs.js +1647 -1514
- package/index.es.js +546 -413
- package/package.json +1 -1
- package/src/DataTable/Columns.js +12 -4
- package/src/DataTable/DisplayOptions.js +27 -122
- package/src/DataTable/DraggableColumnOptions.js +176 -0
- package/src/DataTable/SortableColumns.js +38 -26
- package/src/DataTable/ThComponent.js +22 -9
- package/src/DataTable/dragNoticeEl.js +13 -0
- package/src/DataTable/index.js +65 -129
- package/src/DataTable/style.css +13 -0
- package/src/DataTable/utils/queryParams.js +6 -1
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +179 -147
- package/src/DataTable/utils/withTableParams.js +2 -3
- package/src/DataTable/viewColumn.js +0 -1
- package/src/TgSelect/index.js +1 -0
- package/ui.css +13 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelCase, set } from "lodash-es";
|
|
1
|
+
import { camelCase, flatMap, set } from "lodash-es";
|
|
2
2
|
|
|
3
3
|
export function tableQueryParamsToHasuraClauses({
|
|
4
4
|
page,
|
|
@@ -24,48 +24,62 @@ export function tableQueryParamsToHasuraClauses({
|
|
|
24
24
|
const searchTerms = searchTerm.split(",");
|
|
25
25
|
|
|
26
26
|
schema.fields.forEach(field => {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
searchDisabled
|
|
32
|
-
field.filterDisabled ||
|
|
33
|
-
type === "color" ||
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
path,
|
|
30
|
+
additionalSearchPaths = [],
|
|
31
|
+
searchDisabled,
|
|
34
32
|
isHidden
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
} = field;
|
|
34
|
+
const allPaths = [path, ...additionalSearchPaths];
|
|
35
|
+
allPaths.forEach(path => {
|
|
36
|
+
addSearchTermFilters(path);
|
|
37
|
+
});
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
function addSearchTermFilters(path) {
|
|
40
|
+
if (uniqueFieldsByPath[path]) return; // Skip if already added
|
|
41
|
+
uniqueFieldsByPath[path] = true;
|
|
42
|
+
if (
|
|
43
|
+
searchDisabled ||
|
|
44
|
+
field.filterDisabled ||
|
|
45
|
+
type === "color" ||
|
|
46
|
+
isHidden ||
|
|
47
|
+
!path
|
|
48
|
+
)
|
|
49
|
+
return;
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
// Process each search term
|
|
52
|
+
searchTerms.forEach(term => {
|
|
53
|
+
const filterValue = term.trim(); // Trim the term to handle spaces after commas
|
|
54
|
+
|
|
55
|
+
if (type === "string" || type === "lookup") {
|
|
56
|
+
const o = set({}, path, { _ilike: `%${filterValue}%` });
|
|
57
|
+
searchTermFilters.push(o);
|
|
58
|
+
} else if (type === "boolean") {
|
|
59
|
+
let regex;
|
|
60
|
+
try {
|
|
61
|
+
regex = new RegExp("^" + filterValue, "ig");
|
|
62
|
+
} catch (error) {
|
|
63
|
+
//ignore
|
|
64
|
+
}
|
|
65
|
+
if (regex) {
|
|
66
|
+
if ("true".replace(regex, "") !== "true") {
|
|
67
|
+
const o = set({}, path, { _eq: true });
|
|
68
|
+
searchTermFilters.push(o);
|
|
69
|
+
} else if ("false".replace(regex, "") !== "false") {
|
|
70
|
+
const o = set({}, path, { _eq: false });
|
|
71
|
+
searchTermFilters.push(o);
|
|
72
|
+
}
|
|
59
73
|
}
|
|
74
|
+
} else if (
|
|
75
|
+
(type === "number" || type === "integer") &&
|
|
76
|
+
!isNaN(filterValue)
|
|
77
|
+
) {
|
|
78
|
+
const o = set({}, path, { _eq: parseFloat(filterValue) });
|
|
79
|
+
searchTermFilters.push(o);
|
|
60
80
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
!isNaN(filterValue)
|
|
64
|
-
) {
|
|
65
|
-
const o = set({}, path, { _eq: parseFloat(filterValue) });
|
|
66
|
-
searchTermFilters.push(o);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
69
83
|
});
|
|
70
84
|
|
|
71
85
|
if (searchTermFilters.length > 0) {
|
|
@@ -78,11 +92,18 @@ export function tableQueryParamsToHasuraClauses({
|
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
if (filters && filters.length > 0) {
|
|
81
|
-
const filterClauses = filters
|
|
95
|
+
const filterClauses = flatMap(filters, filter => {
|
|
82
96
|
let { selectedFilter, filterOn, filterValue } = filter;
|
|
83
97
|
const fieldSchema = ccFields[filterOn] || {};
|
|
84
98
|
|
|
85
|
-
const {
|
|
99
|
+
const {
|
|
100
|
+
path,
|
|
101
|
+
additionalSearchPaths = [],
|
|
102
|
+
reference,
|
|
103
|
+
type,
|
|
104
|
+
customColumnFilter
|
|
105
|
+
} = fieldSchema;
|
|
106
|
+
|
|
86
107
|
if (customColumnFilter) {
|
|
87
108
|
return customColumnFilter(filterValue);
|
|
88
109
|
}
|
|
@@ -116,121 +137,132 @@ export function tableQueryParamsToHasuraClauses({
|
|
|
116
137
|
|
|
117
138
|
if (reference) {
|
|
118
139
|
filterOn = reference.sourceField;
|
|
140
|
+
return addColumnFilters(filterOn);
|
|
119
141
|
} else {
|
|
120
|
-
|
|
142
|
+
if (path) {
|
|
143
|
+
const allPaths = [path, ...additionalSearchPaths];
|
|
144
|
+
return allPaths.map(p => addColumnFilters(p));
|
|
145
|
+
} else {
|
|
146
|
+
return addColumnFilters(filterOn);
|
|
147
|
+
}
|
|
121
148
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
149
|
+
|
|
150
|
+
function addColumnFilters(filterOn) {
|
|
151
|
+
switch (selectedFilter) {
|
|
152
|
+
case "none":
|
|
153
|
+
return {};
|
|
154
|
+
case "startsWith":
|
|
155
|
+
return { [filterOn]: { _ilike: `${filterValue}%` } };
|
|
156
|
+
case "endsWith":
|
|
157
|
+
return { [filterOn]: { _ilike: `%${filterValue}` } };
|
|
158
|
+
case "contains":
|
|
159
|
+
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
160
|
+
case "notContains":
|
|
161
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
162
|
+
case "isExactly":
|
|
163
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
164
|
+
case "isEmpty":
|
|
165
|
+
if (filterOn.includes(".")) {
|
|
166
|
+
// if we're filtering on a nested field, like a sequence table with parts.name
|
|
167
|
+
// we really want to just query on the top level field's existence
|
|
168
|
+
return {
|
|
169
|
+
_not: {
|
|
170
|
+
[filterOn.split(".")[0]]: {}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
139
174
|
return {
|
|
140
|
-
|
|
141
|
-
[filterOn
|
|
142
|
-
|
|
175
|
+
_or: [
|
|
176
|
+
{ [filterOn]: { _eq: "" } },
|
|
177
|
+
{ [filterOn]: { _is_null: true } }
|
|
178
|
+
]
|
|
143
179
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
]
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
[filterOn]: {
|
|
178
|
-
_gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
180
|
+
case "notEmpty":
|
|
181
|
+
return {
|
|
182
|
+
_and: [
|
|
183
|
+
{ [filterOn]: { _neq: "" } },
|
|
184
|
+
{ [filterOn]: { _is_null: false } }
|
|
185
|
+
]
|
|
186
|
+
};
|
|
187
|
+
case "inList":
|
|
188
|
+
return { [filterOn]: { _in: filterValue } };
|
|
189
|
+
case "notInList":
|
|
190
|
+
return { [filterOn]: { _nin: filterValue } };
|
|
191
|
+
case "true":
|
|
192
|
+
return { [filterOn]: { _eq: true } };
|
|
193
|
+
case "false":
|
|
194
|
+
return { [filterOn]: { _eq: false } };
|
|
195
|
+
case "dateIs":
|
|
196
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
197
|
+
case "notBetween":
|
|
198
|
+
return {
|
|
199
|
+
_or: [
|
|
200
|
+
{
|
|
201
|
+
[filterOn]: {
|
|
202
|
+
_lt: new Date(arrayFilterValue[0])
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
[filterOn]: {
|
|
207
|
+
_gt: new Date(
|
|
208
|
+
new Date(arrayFilterValue[1]).setHours(23, 59)
|
|
209
|
+
)
|
|
210
|
+
}
|
|
179
211
|
}
|
|
212
|
+
]
|
|
213
|
+
};
|
|
214
|
+
case "isBetween":
|
|
215
|
+
return {
|
|
216
|
+
[filterOn]: {
|
|
217
|
+
_gte: new Date(arrayFilterValue[0]),
|
|
218
|
+
_lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
180
219
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
[filterOn]: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
[filterOn]: {
|
|
210
|
-
_lt: parseFloat(arrayFilterValue[0])
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
[filterOn]: {
|
|
215
|
-
_gt: parseFloat(arrayFilterValue[1])
|
|
220
|
+
};
|
|
221
|
+
case "isBefore":
|
|
222
|
+
return { [filterOn]: { _lt: new Date(filterValue) } };
|
|
223
|
+
case "isAfter":
|
|
224
|
+
return { [filterOn]: { _gt: new Date(filterValue) } };
|
|
225
|
+
case "greaterThan":
|
|
226
|
+
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
227
|
+
case "lessThan":
|
|
228
|
+
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
229
|
+
case "inRange":
|
|
230
|
+
return {
|
|
231
|
+
[filterOn]: {
|
|
232
|
+
_gte: parseFloat(arrayFilterValue[0]),
|
|
233
|
+
_lte: parseFloat(arrayFilterValue[1])
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
case "outsideRange":
|
|
237
|
+
return {
|
|
238
|
+
_or: [
|
|
239
|
+
{
|
|
240
|
+
[filterOn]: {
|
|
241
|
+
_lt: parseFloat(arrayFilterValue[0])
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
[filterOn]: {
|
|
246
|
+
_gt: parseFloat(arrayFilterValue[1])
|
|
247
|
+
}
|
|
216
248
|
}
|
|
249
|
+
]
|
|
250
|
+
};
|
|
251
|
+
case "equalTo":
|
|
252
|
+
return {
|
|
253
|
+
[filterOn]: {
|
|
254
|
+
_eq:
|
|
255
|
+
type === "number" || type === "integer"
|
|
256
|
+
? parseFloat(filterValue)
|
|
257
|
+
: filterValue
|
|
217
258
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
? parseFloat(filterValue)
|
|
226
|
-
: filterValue
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
case "regex":
|
|
230
|
-
return { [filterOn]: { _regex: filterValue } };
|
|
231
|
-
default:
|
|
232
|
-
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
233
|
-
return {};
|
|
259
|
+
};
|
|
260
|
+
case "regex":
|
|
261
|
+
return { [filterOn]: { _regex: filterValue } };
|
|
262
|
+
default:
|
|
263
|
+
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
264
|
+
return {};
|
|
265
|
+
}
|
|
234
266
|
}
|
|
235
267
|
});
|
|
236
268
|
|
|
@@ -49,7 +49,6 @@ export const useTableParams = props => {
|
|
|
49
49
|
orderByFirstColumn,
|
|
50
50
|
pageSize,
|
|
51
51
|
schema,
|
|
52
|
-
syncDisplayOptionsToDb,
|
|
53
52
|
tableParams: _tableParams,
|
|
54
53
|
urlConnected,
|
|
55
54
|
withDisplayOptions,
|
|
@@ -164,13 +163,13 @@ export const useTableParams = props => {
|
|
|
164
163
|
_tableConfig?.userSetPageSize &&
|
|
165
164
|
parseInt(_tableConfig.userSetPageSize, 10);
|
|
166
165
|
let _defaultsToUse = defaults;
|
|
167
|
-
if (
|
|
166
|
+
if (userSetPageSize) {
|
|
168
167
|
_defaultsToUse = _defaultsToUse || {};
|
|
169
168
|
_defaultsToUse.pageSize = userSetPageSize;
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
return _defaultsToUse;
|
|
173
|
-
}, [defaults, formName
|
|
172
|
+
}, [defaults, formName]);
|
|
174
173
|
|
|
175
174
|
const passingProps = useMemo(
|
|
176
175
|
() => ({
|
package/src/TgSelect/index.js
CHANGED
package/ui.css
CHANGED
|
@@ -10066,6 +10066,19 @@ body:not(.drag-active)
|
|
|
10066
10066
|
display: flex;
|
|
10067
10067
|
flex-direction: column;
|
|
10068
10068
|
}
|
|
10069
|
+
.th-dragging {
|
|
10070
|
+
z-index: 999 !important;
|
|
10071
|
+
cursor: grabbing !important;
|
|
10072
|
+
opacity: 0.8;
|
|
10073
|
+
background-color: #f5f8fa;
|
|
10074
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
10075
|
+
}
|
|
10076
|
+
|
|
10077
|
+
.bp3-dark .th-dragging {
|
|
10078
|
+
background-color: #30404d;
|
|
10079
|
+
box-shadow: 0 2px 8px rgba(250, 245, 245, 0.15);
|
|
10080
|
+
outline: 1px solid #48aff0;
|
|
10081
|
+
}
|
|
10069
10082
|
.dna-loader {
|
|
10070
10083
|
display: inline-block;
|
|
10071
10084
|
position: relative;
|