@teselagen/ui 0.8.6-beta.2 → 0.8.6-beta.21
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/utils/initializeHasuraWhereAndFilter.d.ts +0 -1
- package/DataTable/utils/queryParams.d.ts +13 -2
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +1 -1
- package/README.md +1 -1
- package/index.cjs.js +312 -127
- package/index.d.ts +1 -0
- package/index.es.js +312 -127
- package/package.json +1 -1
- package/src/DataTable/Columns.js +1 -1
- package/src/DataTable/index.js +2 -2
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +131 -8
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +719 -21
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +1 -12
- package/src/DataTable/utils/queryParams.js +176 -91
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +185 -168
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +50 -11
- package/src/index.js +1 -0
- package/src/utils/determineBlackOrWhiteTextColor.js +8 -1
- package/utils/determineBlackOrWhiteTextColor.d.ts +1 -2
package/index.es.js
CHANGED
|
@@ -7999,6 +7999,16 @@ function forEach(collection, iteratee) {
|
|
|
7999
7999
|
return func(collection, castFunction(iteratee));
|
|
8000
8000
|
}
|
|
8001
8001
|
__name(forEach, "forEach");
|
|
8002
|
+
function endsWith$1(string2, target, position2) {
|
|
8003
|
+
string2 = toString$4(string2);
|
|
8004
|
+
target = baseToString$1(target);
|
|
8005
|
+
var length = string2.length;
|
|
8006
|
+
position2 = position2 === void 0 ? length : baseClamp(toInteger(position2), 0, length);
|
|
8007
|
+
var end2 = position2;
|
|
8008
|
+
position2 -= target.length;
|
|
8009
|
+
return position2 >= 0 && string2.slice(position2, end2) == target;
|
|
8010
|
+
}
|
|
8011
|
+
__name(endsWith$1, "endsWith$1");
|
|
8002
8012
|
function arrayEvery(array2, predicate) {
|
|
8003
8013
|
var index2 = -1, length = array2 == null ? 0 : array2.length;
|
|
8004
8014
|
while (++index2 < length) {
|
|
@@ -19397,37 +19407,43 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19397
19407
|
}) {
|
|
19398
19408
|
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19399
19409
|
let where = {};
|
|
19400
|
-
const order_by =
|
|
19410
|
+
const order_by = [];
|
|
19401
19411
|
const limit = pageSize || 25;
|
|
19402
19412
|
const offset3 = page && pageSize ? (page - 1) * pageSize : 0;
|
|
19403
19413
|
if (searchTerm) {
|
|
19404
19414
|
const searchTermFilters = [];
|
|
19415
|
+
const uniqueFieldsByPath = {};
|
|
19416
|
+
const searchTerms = searchTerm.split(",");
|
|
19405
19417
|
schema.fields.forEach((field) => {
|
|
19406
19418
|
const { type: type2, path: path2, searchDisabled } = field;
|
|
19419
|
+
if (uniqueFieldsByPath[path2]) return;
|
|
19420
|
+
uniqueFieldsByPath[path2] = true;
|
|
19407
19421
|
if (searchDisabled || field.filterDisabled || type2 === "color") return;
|
|
19408
|
-
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
|
|
19412
|
-
|
|
19413
|
-
|
|
19414
|
-
|
|
19415
|
-
|
|
19416
|
-
|
|
19417
|
-
|
|
19418
|
-
|
|
19419
|
-
if (
|
|
19420
|
-
|
|
19421
|
-
|
|
19422
|
-
|
|
19423
|
-
|
|
19424
|
-
|
|
19422
|
+
searchTerms.forEach((term) => {
|
|
19423
|
+
const filterValue = term.trim();
|
|
19424
|
+
if (type2 === "string" || type2 === "lookup") {
|
|
19425
|
+
const o2 = set$1({}, path2, { _ilike: `%${filterValue}%` });
|
|
19426
|
+
searchTermFilters.push(o2);
|
|
19427
|
+
} else if (type2 === "boolean") {
|
|
19428
|
+
let regex;
|
|
19429
|
+
try {
|
|
19430
|
+
regex = new RegExp("^" + filterValue, "ig");
|
|
19431
|
+
} catch (error) {
|
|
19432
|
+
}
|
|
19433
|
+
if (regex) {
|
|
19434
|
+
if ("true".replace(regex, "") !== "true") {
|
|
19435
|
+
const o2 = set$1({}, path2, { _eq: true });
|
|
19436
|
+
searchTermFilters.push(o2);
|
|
19437
|
+
} else if ("false".replace(regex, "") !== "false") {
|
|
19438
|
+
const o2 = set$1({}, path2, { _eq: false });
|
|
19439
|
+
searchTermFilters.push(o2);
|
|
19440
|
+
}
|
|
19425
19441
|
}
|
|
19442
|
+
} else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
|
|
19443
|
+
const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
|
|
19444
|
+
searchTermFilters.push(o2);
|
|
19426
19445
|
}
|
|
19427
|
-
}
|
|
19428
|
-
const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
|
|
19429
|
-
searchTermFilters.push(o2);
|
|
19430
|
-
}
|
|
19446
|
+
});
|
|
19431
19447
|
});
|
|
19432
19448
|
if (searchTermFilters.length > 0) {
|
|
19433
19449
|
if (Object.keys(where).length > 0) {
|
|
@@ -19441,7 +19457,10 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19441
19457
|
const filterClauses = filters.map((filter2) => {
|
|
19442
19458
|
let { selectedFilter, filterOn, filterValue } = filter2;
|
|
19443
19459
|
const fieldSchema = ccFields[filterOn] || {};
|
|
19444
|
-
const { path: path2, reference: reference2, type: type2 } = fieldSchema;
|
|
19460
|
+
const { path: path2, reference: reference2, type: type2, customColumnFilter } = fieldSchema;
|
|
19461
|
+
if (customColumnFilter) {
|
|
19462
|
+
return customColumnFilter(filterValue);
|
|
19463
|
+
}
|
|
19445
19464
|
let stringFilterValue = filterValue && filterValue.toString ? filterValue.toString() : filterValue;
|
|
19446
19465
|
if (stringFilterValue === false) {
|
|
19447
19466
|
stringFilterValue = "false";
|
|
@@ -19474,10 +19493,17 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19474
19493
|
case "contains":
|
|
19475
19494
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19476
19495
|
case "notContains":
|
|
19477
|
-
return { [filterOn]: {
|
|
19496
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
19478
19497
|
case "isExactly":
|
|
19479
19498
|
return { [filterOn]: { _eq: filterValue } };
|
|
19480
19499
|
case "isEmpty":
|
|
19500
|
+
if (filterOn.includes(".")) {
|
|
19501
|
+
return {
|
|
19502
|
+
_not: {
|
|
19503
|
+
[filterOn.split(".")[0]]: {}
|
|
19504
|
+
}
|
|
19505
|
+
};
|
|
19506
|
+
}
|
|
19481
19507
|
return {
|
|
19482
19508
|
_or: [
|
|
19483
19509
|
{ [filterOn]: { _eq: "" } },
|
|
@@ -19511,9 +19537,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19511
19537
|
},
|
|
19512
19538
|
{
|
|
19513
19539
|
[filterOn]: {
|
|
19514
|
-
_gt: new Date(
|
|
19515
|
-
new Date(arrayFilterValue[1]).setHours(23, 59)
|
|
19516
|
-
)
|
|
19540
|
+
_gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19517
19541
|
}
|
|
19518
19542
|
}
|
|
19519
19543
|
]
|
|
@@ -19567,10 +19591,6 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19567
19591
|
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
19568
19592
|
return {};
|
|
19569
19593
|
}
|
|
19570
|
-
}).map((filter2) => {
|
|
19571
|
-
const o2 = {};
|
|
19572
|
-
set$1(o2, Object.keys(filter2)[0], filter2[Object.keys(filter2)[0]]);
|
|
19573
|
-
return o2;
|
|
19574
19594
|
});
|
|
19575
19595
|
if (filterClauses.length > 0) {
|
|
19576
19596
|
if (Object.keys(where).length > 0) {
|
|
@@ -19584,7 +19604,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19584
19604
|
order2.forEach((item) => {
|
|
19585
19605
|
const field = item.startsWith("-") ? item.substring(1) : item;
|
|
19586
19606
|
const direction = item.startsWith("-") ? "desc" : "asc";
|
|
19587
|
-
order_by[field]
|
|
19607
|
+
order_by.push({ [field]: direction });
|
|
19588
19608
|
});
|
|
19589
19609
|
}
|
|
19590
19610
|
if (additionalFilter) {
|
|
@@ -19616,6 +19636,7 @@ function filterLocalEntitiesToHasura(records, { where, order_by, limit, offset:
|
|
|
19616
19636
|
if (order_by) {
|
|
19617
19637
|
filteredRecords = applyOrderBy(filteredRecords, order_by);
|
|
19618
19638
|
}
|
|
19639
|
+
filteredRecords = restoreEntitiesFromLocalFilter(filteredRecords);
|
|
19619
19640
|
const allFilteredRecords = [...filteredRecords];
|
|
19620
19641
|
if (!isInfinite && offset3 !== void 0) {
|
|
19621
19642
|
filteredRecords = filteredRecords.slice(offset3);
|
|
@@ -19655,7 +19676,7 @@ function applyWhereClause(records, where) {
|
|
|
19655
19676
|
return false;
|
|
19656
19677
|
}
|
|
19657
19678
|
} else {
|
|
19658
|
-
const value = record
|
|
19679
|
+
const value = get$3(record, key);
|
|
19659
19680
|
const conditions = filter2[key];
|
|
19660
19681
|
if (isObject$2(value) && isObject$2(conditions) && !hasOperator(conditions)) {
|
|
19661
19682
|
return applyFilter(value, conditions);
|
|
@@ -19764,35 +19785,111 @@ function applyWhereClause(records, where) {
|
|
|
19764
19785
|
return records.filter((record) => applyFilter(record, where));
|
|
19765
19786
|
}
|
|
19766
19787
|
__name(applyWhereClause, "applyWhereClause");
|
|
19767
|
-
function applyOrderBy(records,
|
|
19768
|
-
const
|
|
19769
|
-
if (
|
|
19770
|
-
const
|
|
19771
|
-
const
|
|
19772
|
-
|
|
19788
|
+
function applyOrderBy(records, _order_by) {
|
|
19789
|
+
const order_by = isArray$2(_order_by) ? _order_by : isEmpty$1(_order_by) ? [] : [_order_by];
|
|
19790
|
+
if (order_by.length > 0) {
|
|
19791
|
+
const orderFuncs = [];
|
|
19792
|
+
const ascOrDescArray = [];
|
|
19793
|
+
order_by.forEach(
|
|
19794
|
+
({ path: path2, direction, type: type2, sortFn, getValueToFilterOn, ownProps }) => {
|
|
19795
|
+
direction = direction || "desc";
|
|
19796
|
+
if (sortFn) {
|
|
19797
|
+
const sortFnArray = Array.isArray(sortFn) ? sortFn : [sortFn];
|
|
19798
|
+
sortFnArray.forEach((fn4) => {
|
|
19799
|
+
const getter = typeof fn4 === "function" ? fn4 : (r2) => get$3(r2, fn4);
|
|
19800
|
+
orderFuncs.push((r2) => {
|
|
19801
|
+
const val = getter(r2);
|
|
19802
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19803
|
+
});
|
|
19804
|
+
ascOrDescArray.push("desc");
|
|
19805
|
+
orderFuncs.push(getter);
|
|
19806
|
+
ascOrDescArray.push(direction);
|
|
19807
|
+
});
|
|
19808
|
+
} else if (getValueToFilterOn) {
|
|
19809
|
+
orderFuncs.push((r2) => {
|
|
19810
|
+
const val = getValueToFilterOn(r2, ownProps);
|
|
19811
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19812
|
+
});
|
|
19813
|
+
ascOrDescArray.push("desc");
|
|
19814
|
+
orderFuncs.push((r2) => getValueToFilterOn(r2, ownProps));
|
|
19815
|
+
ascOrDescArray.push(direction);
|
|
19816
|
+
} else if (type2 === "timestamp") {
|
|
19817
|
+
orderFuncs.push((r2) => {
|
|
19818
|
+
const val = get$3(r2, path2);
|
|
19819
|
+
return val ? 1 : 0;
|
|
19820
|
+
});
|
|
19821
|
+
ascOrDescArray.push("desc");
|
|
19822
|
+
orderFuncs.push((r2) => {
|
|
19823
|
+
const val = get$3(r2, path2);
|
|
19824
|
+
return val ? new Date(val).getTime() : -Infinity;
|
|
19825
|
+
});
|
|
19826
|
+
ascOrDescArray.push(direction);
|
|
19827
|
+
} else if (path2 && endsWith$1(path2.toLowerCase(), "id")) {
|
|
19828
|
+
orderFuncs.push((r2) => {
|
|
19829
|
+
const val = get$3(r2, path2);
|
|
19830
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19831
|
+
});
|
|
19832
|
+
ascOrDescArray.push("desc");
|
|
19833
|
+
orderFuncs.push((o2) => {
|
|
19834
|
+
const val = get$3(o2, path2);
|
|
19835
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19836
|
+
return parseInt(val, 10) || 0;
|
|
19837
|
+
});
|
|
19838
|
+
ascOrDescArray.push(direction);
|
|
19839
|
+
} else {
|
|
19840
|
+
orderFuncs.push((r2) => {
|
|
19841
|
+
const val = get$3(r2, path2);
|
|
19842
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19843
|
+
});
|
|
19844
|
+
ascOrDescArray.push("desc");
|
|
19845
|
+
orderFuncs.push((r2) => {
|
|
19846
|
+
const val = get$3(r2, path2);
|
|
19847
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19848
|
+
if (isString$1(val)) {
|
|
19849
|
+
return val.toLowerCase().replace(
|
|
19850
|
+
/(\d+)/g,
|
|
19851
|
+
(num) => (
|
|
19852
|
+
// Pad numbers with leading zeros for proper natural sort
|
|
19853
|
+
num.padStart(10, "0")
|
|
19854
|
+
)
|
|
19855
|
+
);
|
|
19856
|
+
}
|
|
19857
|
+
return val;
|
|
19858
|
+
});
|
|
19859
|
+
ascOrDescArray.push(direction);
|
|
19860
|
+
}
|
|
19861
|
+
}
|
|
19862
|
+
);
|
|
19863
|
+
records = orderBy$1(records, orderFuncs, ascOrDescArray);
|
|
19773
19864
|
}
|
|
19774
19865
|
return records;
|
|
19775
19866
|
}
|
|
19776
19867
|
__name(applyOrderBy, "applyOrderBy");
|
|
19868
|
+
function restoreEntitiesFromLocalFilter(ents) {
|
|
19869
|
+
return ents.map((entity) => {
|
|
19870
|
+
forEach(entity, (val, key) => {
|
|
19871
|
+
var _a;
|
|
19872
|
+
if ((_a = key.startsWith) == null ? void 0 : _a.call(key, "___original___")) {
|
|
19873
|
+
entity[key.slice("___original___".length)] = val;
|
|
19874
|
+
delete entity[key];
|
|
19875
|
+
}
|
|
19876
|
+
});
|
|
19877
|
+
return entity;
|
|
19878
|
+
});
|
|
19879
|
+
}
|
|
19880
|
+
__name(restoreEntitiesFromLocalFilter, "restoreEntitiesFromLocalFilter");
|
|
19777
19881
|
function initializeHasuraWhereAndFilter(additionalFilter, where = {}, currentParams) {
|
|
19778
19882
|
where._and = where._and || [];
|
|
19779
19883
|
where._or = where._or || [];
|
|
19780
19884
|
if (typeof additionalFilter === "function") {
|
|
19781
19885
|
const newWhere = additionalFilter(where, currentParams);
|
|
19782
19886
|
if (newWhere) {
|
|
19783
|
-
|
|
19887
|
+
Object.assign(where, newWhere);
|
|
19784
19888
|
}
|
|
19785
19889
|
} else if (typeof additionalFilter === "object")
|
|
19786
19890
|
where._and.push(additionalFilter);
|
|
19787
19891
|
}
|
|
19788
19892
|
__name(initializeHasuraWhereAndFilter, "initializeHasuraWhereAndFilter");
|
|
19789
|
-
const addCustomColumnFilters = /* @__PURE__ */ __name((where, fields, currentParams) => {
|
|
19790
|
-
fields.forEach((field) => {
|
|
19791
|
-
const { customColumnFilter, filterDisabled } = field;
|
|
19792
|
-
if (filterDisabled || !customColumnFilter) return;
|
|
19793
|
-
customColumnFilter(where, currentParams);
|
|
19794
|
-
});
|
|
19795
|
-
}, "addCustomColumnFilters");
|
|
19796
19893
|
const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
|
|
19797
19894
|
function safeStringify(val) {
|
|
19798
19895
|
if (val !== null && typeof val === "object") {
|
|
@@ -19967,9 +20064,22 @@ function makeDataTableHandlers({
|
|
|
19967
20064
|
};
|
|
19968
20065
|
}
|
|
19969
20066
|
__name(makeDataTableHandlers, "makeDataTableHandlers");
|
|
20067
|
+
function cleanupFilters({ filters, ccFields }) {
|
|
20068
|
+
(filters || []).forEach((filter2) => {
|
|
20069
|
+
const { filterOn, filterValue } = filter2;
|
|
20070
|
+
const field = ccFields[filterOn];
|
|
20071
|
+
if (field.type === "number" || field.type === "integer") {
|
|
20072
|
+
filter2.filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
20073
|
+
}
|
|
20074
|
+
if (filter2.selectedFilter === "inList" && typeof filter2.filterValue === "number") {
|
|
20075
|
+
filter2.filterValue = filter2.filterValue.toString();
|
|
20076
|
+
}
|
|
20077
|
+
});
|
|
20078
|
+
}
|
|
20079
|
+
__name(cleanupFilters, "cleanupFilters");
|
|
19970
20080
|
function getQueryParams({
|
|
19971
20081
|
currentParams,
|
|
19972
|
-
|
|
20082
|
+
urlConnected,
|
|
19973
20083
|
defaults,
|
|
19974
20084
|
schema,
|
|
19975
20085
|
isInfinite,
|
|
@@ -19978,88 +20088,145 @@ function getQueryParams({
|
|
|
19978
20088
|
additionalFilter,
|
|
19979
20089
|
doNotCoercePageSize,
|
|
19980
20090
|
noOrderError,
|
|
19981
|
-
|
|
20091
|
+
isCodeModel,
|
|
19982
20092
|
ownProps
|
|
19983
20093
|
}) {
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
|
|
19990
|
-
let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
|
|
19991
|
-
if (page <= 0 || isNaN(page)) {
|
|
19992
|
-
page = void 0;
|
|
19993
|
-
}
|
|
19994
|
-
if (isInfinite) {
|
|
19995
|
-
page = void 0;
|
|
19996
|
-
pageSize = void 0;
|
|
19997
|
-
}
|
|
19998
|
-
if (pageSize !== void 0 && !doNotCoercePageSize) {
|
|
19999
|
-
const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
|
|
20000
|
-
(a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
|
|
20001
|
-
)[0];
|
|
20002
|
-
pageSize = closest;
|
|
20003
|
-
}
|
|
20004
|
-
const cleanedOrder = [];
|
|
20005
|
-
if (order2 && order2.length) {
|
|
20006
|
-
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20007
|
-
order2.forEach((orderVal) => {
|
|
20008
|
-
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20009
|
-
const schemaForField = ccFields[ccDisplayName];
|
|
20010
|
-
if (schemaForField) {
|
|
20011
|
-
const { path: path2 } = schemaForField;
|
|
20012
|
-
const reversed = ccDisplayName !== orderVal;
|
|
20013
|
-
const prefix2 = reversed ? "-" : "";
|
|
20014
|
-
cleanedOrder.push(prefix2 + path2);
|
|
20015
|
-
} else {
|
|
20016
|
-
!noOrderError && console.error(
|
|
20017
|
-
"No schema for field found!",
|
|
20018
|
-
ccDisplayName,
|
|
20019
|
-
JSON.stringify(schema.fields, null, 2)
|
|
20020
|
-
);
|
|
20094
|
+
let errorParsingUrlString;
|
|
20095
|
+
try {
|
|
20096
|
+
Object.keys(currentParams).forEach(function(key) {
|
|
20097
|
+
if (currentParams[key] === void 0) {
|
|
20098
|
+
delete currentParams[key];
|
|
20021
20099
|
}
|
|
20022
20100
|
});
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
pageSize
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
|
|
20049
|
-
|
|
20050
|
-
|
|
20051
|
-
|
|
20052
|
-
|
|
20053
|
-
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20101
|
+
const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
|
|
20102
|
+
let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
|
|
20103
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20104
|
+
cleanupFilters({ filters, ccFields });
|
|
20105
|
+
if (page <= 0 || isNaN(page)) {
|
|
20106
|
+
page = void 0;
|
|
20107
|
+
}
|
|
20108
|
+
if (isInfinite) {
|
|
20109
|
+
page = void 0;
|
|
20110
|
+
pageSize = void 0;
|
|
20111
|
+
}
|
|
20112
|
+
if (pageSize !== void 0 && !doNotCoercePageSize) {
|
|
20113
|
+
const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
|
|
20114
|
+
(a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
|
|
20115
|
+
)[0];
|
|
20116
|
+
pageSize = closest;
|
|
20117
|
+
}
|
|
20118
|
+
const cleanedOrder = [];
|
|
20119
|
+
if (order2 && order2.length) {
|
|
20120
|
+
order2.forEach((orderVal) => {
|
|
20121
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20122
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
20123
|
+
if (schemaForField) {
|
|
20124
|
+
const { path: path2 } = schemaForField;
|
|
20125
|
+
const reversed = ccDisplayName !== orderVal;
|
|
20126
|
+
const prefix2 = reversed ? "-" : "";
|
|
20127
|
+
cleanedOrder.push(prefix2 + path2);
|
|
20128
|
+
} else {
|
|
20129
|
+
!noOrderError && console.error(
|
|
20130
|
+
"No schema for field found!",
|
|
20131
|
+
ccDisplayName,
|
|
20132
|
+
JSON.stringify(schema.fields, null, 2)
|
|
20133
|
+
);
|
|
20134
|
+
}
|
|
20135
|
+
});
|
|
20136
|
+
}
|
|
20137
|
+
let toRet = {
|
|
20138
|
+
//these are values that might be generally useful for the wrapped component
|
|
20139
|
+
page,
|
|
20140
|
+
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
20141
|
+
order: cleanedOrder,
|
|
20142
|
+
filters,
|
|
20143
|
+
searchTerm
|
|
20144
|
+
};
|
|
20145
|
+
const { where, order_by, limit, offset: offset3 } = tableQueryParamsToHasuraClauses({
|
|
20146
|
+
page,
|
|
20147
|
+
pageSize,
|
|
20148
|
+
searchTerm,
|
|
20149
|
+
filters,
|
|
20150
|
+
order: cleanedOrder,
|
|
20151
|
+
schema
|
|
20059
20152
|
});
|
|
20153
|
+
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
20154
|
+
if (isLocalCall) {
|
|
20155
|
+
const newEnts = filterLocalEntitiesToHasura(
|
|
20156
|
+
prepEntitiesForLocalFilter({ entities, ccFields }),
|
|
20157
|
+
{
|
|
20158
|
+
where,
|
|
20159
|
+
order_by: (Array.isArray(order_by) ? order_by : [order_by]).map(
|
|
20160
|
+
(obj) => {
|
|
20161
|
+
const path2 = Object.keys(obj)[0];
|
|
20162
|
+
return __spreadValues({
|
|
20163
|
+
path: path2,
|
|
20164
|
+
direction: obj[path2],
|
|
20165
|
+
ownProps
|
|
20166
|
+
}, ccFields[path2]);
|
|
20167
|
+
}
|
|
20168
|
+
),
|
|
20169
|
+
limit,
|
|
20170
|
+
offset: offset3,
|
|
20171
|
+
isInfinite
|
|
20172
|
+
}
|
|
20173
|
+
);
|
|
20174
|
+
toRet = __spreadValues(__spreadValues({}, toRet), newEnts);
|
|
20175
|
+
return toRet;
|
|
20176
|
+
} else {
|
|
20177
|
+
if (!order_by.length) {
|
|
20178
|
+
order_by.push({ updatedAt: "desc" });
|
|
20179
|
+
}
|
|
20180
|
+
order_by.push(
|
|
20181
|
+
isCodeModel ? { code: "desc" } : { [window.__sortId || "id"]: "desc" }
|
|
20182
|
+
);
|
|
20183
|
+
return __spreadProps(__spreadValues({}, toRet), {
|
|
20184
|
+
variables: {
|
|
20185
|
+
where,
|
|
20186
|
+
order_by,
|
|
20187
|
+
limit,
|
|
20188
|
+
offset: offset3
|
|
20189
|
+
}
|
|
20190
|
+
});
|
|
20191
|
+
}
|
|
20192
|
+
} catch (e) {
|
|
20193
|
+
if (urlConnected) {
|
|
20194
|
+
errorParsingUrlString = e;
|
|
20195
|
+
console.error(
|
|
20196
|
+
"The following error occurred when trying to build the query params. This is probably due to a malformed URL:",
|
|
20197
|
+
e
|
|
20198
|
+
);
|
|
20199
|
+
return {
|
|
20200
|
+
errorParsingUrlString,
|
|
20201
|
+
variables: {
|
|
20202
|
+
where: {},
|
|
20203
|
+
order_by: [],
|
|
20204
|
+
limit: 0,
|
|
20205
|
+
offset: 0
|
|
20206
|
+
}
|
|
20207
|
+
};
|
|
20208
|
+
} else {
|
|
20209
|
+
console.error("Error building query params from filter:");
|
|
20210
|
+
throw e;
|
|
20211
|
+
}
|
|
20060
20212
|
}
|
|
20061
20213
|
}
|
|
20062
20214
|
__name(getQueryParams, "getQueryParams");
|
|
20215
|
+
function prepEntitiesForLocalFilter({ entities, ccFields }) {
|
|
20216
|
+
const r2 = entities.map((entity) => {
|
|
20217
|
+
const newEnt = __spreadValues({}, entity);
|
|
20218
|
+
forEach(ccFields, ({ getValueToFilterOn, path: path2 }) => {
|
|
20219
|
+
if (getValueToFilterOn) {
|
|
20220
|
+
newEnt["___original___" + path2] = newEnt[path2];
|
|
20221
|
+
const value = getValueToFilterOn(newEnt);
|
|
20222
|
+
newEnt[path2] = value;
|
|
20223
|
+
}
|
|
20224
|
+
});
|
|
20225
|
+
return newEnt;
|
|
20226
|
+
});
|
|
20227
|
+
return r2;
|
|
20228
|
+
}
|
|
20229
|
+
__name(prepEntitiesForLocalFilter, "prepEntitiesForLocalFilter");
|
|
20063
20230
|
function PagingInput({ disabled, onBlur, defaultPage }) {
|
|
20064
20231
|
const [page, setPage] = useState(defaultPage);
|
|
20065
20232
|
const defaultValue2 = useRef(defaultPage);
|
|
@@ -31863,7 +32030,15 @@ function requireColor() {
|
|
|
31863
32030
|
__name(requireColor, "requireColor");
|
|
31864
32031
|
var colorExports = requireColor();
|
|
31865
32032
|
const Color = /* @__PURE__ */ getDefaultExportFromCjs(colorExports);
|
|
31866
|
-
|
|
32033
|
+
function determineBlackOrWhiteTextColor(c2) {
|
|
32034
|
+
try {
|
|
32035
|
+
return Color(c2).isLight() ? "#000000" : "#FFFFFF";
|
|
32036
|
+
} catch (e) {
|
|
32037
|
+
console.error("Error in color parsing:", e);
|
|
32038
|
+
return "#000000";
|
|
32039
|
+
}
|
|
32040
|
+
}
|
|
32041
|
+
__name(determineBlackOrWhiteTextColor, "determineBlackOrWhiteTextColor");
|
|
31867
32042
|
function getTagsAndTagOptions(allTags) {
|
|
31868
32043
|
return flatMap(allTags, (tag) => {
|
|
31869
32044
|
if (tag.tagOptions && tag.tagOptions.length) {
|
|
@@ -51186,7 +51361,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
|
|
|
51186
51361
|
if (order2 && order2.length) {
|
|
51187
51362
|
order2.forEach((order22) => {
|
|
51188
51363
|
const orderField = order22.replace("-", "");
|
|
51189
|
-
if (orderField ===
|
|
51364
|
+
if (orderField === path2) {
|
|
51190
51365
|
if (orderField === order22) {
|
|
51191
51366
|
ordering = "asc";
|
|
51192
51367
|
} else {
|
|
@@ -56277,6 +56452,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
56277
56452
|
doNotCoercePageSize,
|
|
56278
56453
|
currentParams,
|
|
56279
56454
|
entities: props.entities,
|
|
56455
|
+
// for local table
|
|
56456
|
+
urlConnected,
|
|
56280
56457
|
defaults,
|
|
56281
56458
|
schema: convertedSchema,
|
|
56282
56459
|
isInfinite,
|
|
@@ -58669,7 +58846,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58669
58846
|
try {
|
|
58670
58847
|
const allEntities = yield safeQuery(fragment, {
|
|
58671
58848
|
variables: {
|
|
58672
|
-
|
|
58849
|
+
where: variables.where,
|
|
58673
58850
|
sort: variables.sort
|
|
58674
58851
|
},
|
|
58675
58852
|
canCancel: true
|
|
@@ -69049,6 +69226,7 @@ function parseCsvOrExcelFile(_0) {
|
|
|
69049
69226
|
}
|
|
69050
69227
|
__name(parseCsvOrExcelFile, "parseCsvOrExcelFile");
|
|
69051
69228
|
const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(void 0, null, function* () {
|
|
69229
|
+
var _a, _b, _c, _d;
|
|
69052
69230
|
if (!file || Array.isArray(file) && !file.length) return [];
|
|
69053
69231
|
const zipExtracted = yield extractZipFiles(file);
|
|
69054
69232
|
const acceptedFiles = [];
|
|
@@ -69058,9 +69236,12 @@ const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(void
|
|
|
69058
69236
|
}
|
|
69059
69237
|
}
|
|
69060
69238
|
if (acceptedFiles.length && acceptedFiles.length < zipExtracted.length)
|
|
69061
|
-
window.toastr.warning
|
|
69239
|
+
(_b = (_a = window == null ? void 0 : window.toastr) == null ? void 0 : _a.warning) == null ? void 0 : _b.call(
|
|
69240
|
+
_a,
|
|
69241
|
+
"Some files don't have the proper file extension."
|
|
69242
|
+
);
|
|
69062
69243
|
if (!acceptedFiles.length)
|
|
69063
|
-
window.toastr.warning("No files with the proper extension were found.");
|
|
69244
|
+
(_d = (_c = window == null ? void 0 : window.toastr) == null ? void 0 : _c.warning) == null ? void 0 : _d.call(_c, "No files with the proper extension were found.");
|
|
69064
69245
|
return acceptedFiles;
|
|
69065
69246
|
}), "filterFilesInZip");
|
|
69066
69247
|
function removeExt(filename) {
|
|
@@ -71788,12 +71969,15 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71788
71969
|
doNotCoercePageSize,
|
|
71789
71970
|
currentParams,
|
|
71790
71971
|
entities,
|
|
71972
|
+
// for local table
|
|
71973
|
+
urlConnected,
|
|
71791
71974
|
defaults: defaultsToUse,
|
|
71792
71975
|
schema: convertedSchema,
|
|
71793
71976
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71794
71977
|
isLocalCall,
|
|
71795
71978
|
additionalFilter,
|
|
71796
71979
|
noOrderError,
|
|
71980
|
+
isCodeModel,
|
|
71797
71981
|
ownProps: passingProps
|
|
71798
71982
|
});
|
|
71799
71983
|
}, [
|
|
@@ -77953,6 +78137,7 @@ export {
|
|
|
77953
78137
|
createDynamicMenu,
|
|
77954
78138
|
createMenu,
|
|
77955
78139
|
designIcon,
|
|
78140
|
+
determineBlackOrWhiteTextColor,
|
|
77956
78141
|
dnaIcon,
|
|
77957
78142
|
doesSearchValMatchText,
|
|
77958
78143
|
driveIcon,
|
package/package.json
CHANGED
package/src/DataTable/Columns.js
CHANGED
|
@@ -104,7 +104,7 @@ const RenderColumnHeader = ({
|
|
|
104
104
|
if (order && order.length) {
|
|
105
105
|
order.forEach(order => {
|
|
106
106
|
const orderField = order.replace("-", "");
|
|
107
|
-
if (orderField ===
|
|
107
|
+
if (orderField === path) {
|
|
108
108
|
if (orderField === order) {
|
|
109
109
|
ordering = "asc";
|
|
110
110
|
} else {
|
package/src/DataTable/index.js
CHANGED
|
@@ -92,9 +92,9 @@ import { viewColumn, openColumn, multiViewColumn } from "./viewColumn";
|
|
|
92
92
|
import convertSchema from "./utils/convertSchema";
|
|
93
93
|
import TableFormTrackerContext from "./TableFormTrackerContext";
|
|
94
94
|
import {
|
|
95
|
-
getCurrentParamsFromUrl,
|
|
96
95
|
getQueryParams,
|
|
97
96
|
makeDataTableHandlers,
|
|
97
|
+
getCurrentParamsFromUrl,
|
|
98
98
|
setCurrentParamsOnUrl
|
|
99
99
|
} from "./utils/queryParams";
|
|
100
100
|
import { useColumns } from "./Columns";
|
|
@@ -3078,7 +3078,7 @@ const DataTable = ({
|
|
|
3078
3078
|
try {
|
|
3079
3079
|
const allEntities = await safeQuery(fragment, {
|
|
3080
3080
|
variables: {
|
|
3081
|
-
|
|
3081
|
+
where: variables.where,
|
|
3082
3082
|
sort: variables.sort
|
|
3083
3083
|
},
|
|
3084
3084
|
canCancel: true
|