@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.cjs.js
CHANGED
|
@@ -8017,6 +8017,16 @@ function forEach(collection, iteratee) {
|
|
|
8017
8017
|
return func(collection, castFunction(iteratee));
|
|
8018
8018
|
}
|
|
8019
8019
|
__name(forEach, "forEach");
|
|
8020
|
+
function endsWith$1(string2, target, position2) {
|
|
8021
|
+
string2 = toString$4(string2);
|
|
8022
|
+
target = baseToString$1(target);
|
|
8023
|
+
var length = string2.length;
|
|
8024
|
+
position2 = position2 === void 0 ? length : baseClamp(toInteger(position2), 0, length);
|
|
8025
|
+
var end2 = position2;
|
|
8026
|
+
position2 -= target.length;
|
|
8027
|
+
return position2 >= 0 && string2.slice(position2, end2) == target;
|
|
8028
|
+
}
|
|
8029
|
+
__name(endsWith$1, "endsWith$1");
|
|
8020
8030
|
function arrayEvery(array2, predicate) {
|
|
8021
8031
|
var index2 = -1, length = array2 == null ? 0 : array2.length;
|
|
8022
8032
|
while (++index2 < length) {
|
|
@@ -19415,37 +19425,43 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19415
19425
|
}) {
|
|
19416
19426
|
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19417
19427
|
let where = {};
|
|
19418
|
-
const order_by =
|
|
19428
|
+
const order_by = [];
|
|
19419
19429
|
const limit = pageSize || 25;
|
|
19420
19430
|
const offset3 = page && pageSize ? (page - 1) * pageSize : 0;
|
|
19421
19431
|
if (searchTerm) {
|
|
19422
19432
|
const searchTermFilters = [];
|
|
19433
|
+
const uniqueFieldsByPath = {};
|
|
19434
|
+
const searchTerms = searchTerm.split(",");
|
|
19423
19435
|
schema.fields.forEach((field) => {
|
|
19424
19436
|
const { type: type2, path: path2, searchDisabled } = field;
|
|
19437
|
+
if (uniqueFieldsByPath[path2]) return;
|
|
19438
|
+
uniqueFieldsByPath[path2] = true;
|
|
19425
19439
|
if (searchDisabled || field.filterDisabled || type2 === "color") return;
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
if (
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19440
|
+
searchTerms.forEach((term) => {
|
|
19441
|
+
const filterValue = term.trim();
|
|
19442
|
+
if (type2 === "string" || type2 === "lookup") {
|
|
19443
|
+
const o2 = set$1({}, path2, { _ilike: `%${filterValue}%` });
|
|
19444
|
+
searchTermFilters.push(o2);
|
|
19445
|
+
} else if (type2 === "boolean") {
|
|
19446
|
+
let regex;
|
|
19447
|
+
try {
|
|
19448
|
+
regex = new RegExp("^" + filterValue, "ig");
|
|
19449
|
+
} catch (error) {
|
|
19450
|
+
}
|
|
19451
|
+
if (regex) {
|
|
19452
|
+
if ("true".replace(regex, "") !== "true") {
|
|
19453
|
+
const o2 = set$1({}, path2, { _eq: true });
|
|
19454
|
+
searchTermFilters.push(o2);
|
|
19455
|
+
} else if ("false".replace(regex, "") !== "false") {
|
|
19456
|
+
const o2 = set$1({}, path2, { _eq: false });
|
|
19457
|
+
searchTermFilters.push(o2);
|
|
19458
|
+
}
|
|
19443
19459
|
}
|
|
19460
|
+
} else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
|
|
19461
|
+
const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
|
|
19462
|
+
searchTermFilters.push(o2);
|
|
19444
19463
|
}
|
|
19445
|
-
}
|
|
19446
|
-
const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
|
|
19447
|
-
searchTermFilters.push(o2);
|
|
19448
|
-
}
|
|
19464
|
+
});
|
|
19449
19465
|
});
|
|
19450
19466
|
if (searchTermFilters.length > 0) {
|
|
19451
19467
|
if (Object.keys(where).length > 0) {
|
|
@@ -19459,7 +19475,10 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19459
19475
|
const filterClauses = filters.map((filter2) => {
|
|
19460
19476
|
let { selectedFilter, filterOn, filterValue } = filter2;
|
|
19461
19477
|
const fieldSchema = ccFields[filterOn] || {};
|
|
19462
|
-
const { path: path2, reference: reference2, type: type2 } = fieldSchema;
|
|
19478
|
+
const { path: path2, reference: reference2, type: type2, customColumnFilter } = fieldSchema;
|
|
19479
|
+
if (customColumnFilter) {
|
|
19480
|
+
return customColumnFilter(filterValue);
|
|
19481
|
+
}
|
|
19463
19482
|
let stringFilterValue = filterValue && filterValue.toString ? filterValue.toString() : filterValue;
|
|
19464
19483
|
if (stringFilterValue === false) {
|
|
19465
19484
|
stringFilterValue = "false";
|
|
@@ -19492,10 +19511,17 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19492
19511
|
case "contains":
|
|
19493
19512
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19494
19513
|
case "notContains":
|
|
19495
|
-
return { [filterOn]: {
|
|
19514
|
+
return { [filterOn]: { _nilike: `%${filterValue}%` } };
|
|
19496
19515
|
case "isExactly":
|
|
19497
19516
|
return { [filterOn]: { _eq: filterValue } };
|
|
19498
19517
|
case "isEmpty":
|
|
19518
|
+
if (filterOn.includes(".")) {
|
|
19519
|
+
return {
|
|
19520
|
+
_not: {
|
|
19521
|
+
[filterOn.split(".")[0]]: {}
|
|
19522
|
+
}
|
|
19523
|
+
};
|
|
19524
|
+
}
|
|
19499
19525
|
return {
|
|
19500
19526
|
_or: [
|
|
19501
19527
|
{ [filterOn]: { _eq: "" } },
|
|
@@ -19529,9 +19555,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19529
19555
|
},
|
|
19530
19556
|
{
|
|
19531
19557
|
[filterOn]: {
|
|
19532
|
-
_gt: new Date(
|
|
19533
|
-
new Date(arrayFilterValue[1]).setHours(23, 59)
|
|
19534
|
-
)
|
|
19558
|
+
_gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19535
19559
|
}
|
|
19536
19560
|
}
|
|
19537
19561
|
]
|
|
@@ -19585,10 +19609,6 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19585
19609
|
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
19586
19610
|
return {};
|
|
19587
19611
|
}
|
|
19588
|
-
}).map((filter2) => {
|
|
19589
|
-
const o2 = {};
|
|
19590
|
-
set$1(o2, Object.keys(filter2)[0], filter2[Object.keys(filter2)[0]]);
|
|
19591
|
-
return o2;
|
|
19592
19612
|
});
|
|
19593
19613
|
if (filterClauses.length > 0) {
|
|
19594
19614
|
if (Object.keys(where).length > 0) {
|
|
@@ -19602,7 +19622,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19602
19622
|
order2.forEach((item) => {
|
|
19603
19623
|
const field = item.startsWith("-") ? item.substring(1) : item;
|
|
19604
19624
|
const direction = item.startsWith("-") ? "desc" : "asc";
|
|
19605
|
-
order_by[field]
|
|
19625
|
+
order_by.push({ [field]: direction });
|
|
19606
19626
|
});
|
|
19607
19627
|
}
|
|
19608
19628
|
if (additionalFilter) {
|
|
@@ -19634,6 +19654,7 @@ function filterLocalEntitiesToHasura(records, { where, order_by, limit, offset:
|
|
|
19634
19654
|
if (order_by) {
|
|
19635
19655
|
filteredRecords = applyOrderBy(filteredRecords, order_by);
|
|
19636
19656
|
}
|
|
19657
|
+
filteredRecords = restoreEntitiesFromLocalFilter(filteredRecords);
|
|
19637
19658
|
const allFilteredRecords = [...filteredRecords];
|
|
19638
19659
|
if (!isInfinite && offset3 !== void 0) {
|
|
19639
19660
|
filteredRecords = filteredRecords.slice(offset3);
|
|
@@ -19673,7 +19694,7 @@ function applyWhereClause(records, where) {
|
|
|
19673
19694
|
return false;
|
|
19674
19695
|
}
|
|
19675
19696
|
} else {
|
|
19676
|
-
const value = record
|
|
19697
|
+
const value = get$3(record, key);
|
|
19677
19698
|
const conditions = filter2[key];
|
|
19678
19699
|
if (isObject$2(value) && isObject$2(conditions) && !hasOperator(conditions)) {
|
|
19679
19700
|
return applyFilter(value, conditions);
|
|
@@ -19782,35 +19803,111 @@ function applyWhereClause(records, where) {
|
|
|
19782
19803
|
return records.filter((record) => applyFilter(record, where));
|
|
19783
19804
|
}
|
|
19784
19805
|
__name(applyWhereClause, "applyWhereClause");
|
|
19785
|
-
function applyOrderBy(records,
|
|
19786
|
-
const
|
|
19787
|
-
if (
|
|
19788
|
-
const
|
|
19789
|
-
const
|
|
19790
|
-
|
|
19806
|
+
function applyOrderBy(records, _order_by) {
|
|
19807
|
+
const order_by = isArray$2(_order_by) ? _order_by : isEmpty$1(_order_by) ? [] : [_order_by];
|
|
19808
|
+
if (order_by.length > 0) {
|
|
19809
|
+
const orderFuncs = [];
|
|
19810
|
+
const ascOrDescArray = [];
|
|
19811
|
+
order_by.forEach(
|
|
19812
|
+
({ path: path2, direction, type: type2, sortFn, getValueToFilterOn, ownProps }) => {
|
|
19813
|
+
direction = direction || "desc";
|
|
19814
|
+
if (sortFn) {
|
|
19815
|
+
const sortFnArray = Array.isArray(sortFn) ? sortFn : [sortFn];
|
|
19816
|
+
sortFnArray.forEach((fn4) => {
|
|
19817
|
+
const getter = typeof fn4 === "function" ? fn4 : (r2) => get$3(r2, fn4);
|
|
19818
|
+
orderFuncs.push((r2) => {
|
|
19819
|
+
const val = getter(r2);
|
|
19820
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19821
|
+
});
|
|
19822
|
+
ascOrDescArray.push("desc");
|
|
19823
|
+
orderFuncs.push(getter);
|
|
19824
|
+
ascOrDescArray.push(direction);
|
|
19825
|
+
});
|
|
19826
|
+
} else if (getValueToFilterOn) {
|
|
19827
|
+
orderFuncs.push((r2) => {
|
|
19828
|
+
const val = getValueToFilterOn(r2, ownProps);
|
|
19829
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19830
|
+
});
|
|
19831
|
+
ascOrDescArray.push("desc");
|
|
19832
|
+
orderFuncs.push((r2) => getValueToFilterOn(r2, ownProps));
|
|
19833
|
+
ascOrDescArray.push(direction);
|
|
19834
|
+
} else if (type2 === "timestamp") {
|
|
19835
|
+
orderFuncs.push((r2) => {
|
|
19836
|
+
const val = get$3(r2, path2);
|
|
19837
|
+
return val ? 1 : 0;
|
|
19838
|
+
});
|
|
19839
|
+
ascOrDescArray.push("desc");
|
|
19840
|
+
orderFuncs.push((r2) => {
|
|
19841
|
+
const val = get$3(r2, path2);
|
|
19842
|
+
return val ? new Date(val).getTime() : -Infinity;
|
|
19843
|
+
});
|
|
19844
|
+
ascOrDescArray.push(direction);
|
|
19845
|
+
} else if (path2 && endsWith$1(path2.toLowerCase(), "id")) {
|
|
19846
|
+
orderFuncs.push((r2) => {
|
|
19847
|
+
const val = get$3(r2, path2);
|
|
19848
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19849
|
+
});
|
|
19850
|
+
ascOrDescArray.push("desc");
|
|
19851
|
+
orderFuncs.push((o2) => {
|
|
19852
|
+
const val = get$3(o2, path2);
|
|
19853
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19854
|
+
return parseInt(val, 10) || 0;
|
|
19855
|
+
});
|
|
19856
|
+
ascOrDescArray.push(direction);
|
|
19857
|
+
} else {
|
|
19858
|
+
orderFuncs.push((r2) => {
|
|
19859
|
+
const val = get$3(r2, path2);
|
|
19860
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19861
|
+
});
|
|
19862
|
+
ascOrDescArray.push("desc");
|
|
19863
|
+
orderFuncs.push((r2) => {
|
|
19864
|
+
const val = get$3(r2, path2);
|
|
19865
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19866
|
+
if (isString$1(val)) {
|
|
19867
|
+
return val.toLowerCase().replace(
|
|
19868
|
+
/(\d+)/g,
|
|
19869
|
+
(num) => (
|
|
19870
|
+
// Pad numbers with leading zeros for proper natural sort
|
|
19871
|
+
num.padStart(10, "0")
|
|
19872
|
+
)
|
|
19873
|
+
);
|
|
19874
|
+
}
|
|
19875
|
+
return val;
|
|
19876
|
+
});
|
|
19877
|
+
ascOrDescArray.push(direction);
|
|
19878
|
+
}
|
|
19879
|
+
}
|
|
19880
|
+
);
|
|
19881
|
+
records = orderBy$1(records, orderFuncs, ascOrDescArray);
|
|
19791
19882
|
}
|
|
19792
19883
|
return records;
|
|
19793
19884
|
}
|
|
19794
19885
|
__name(applyOrderBy, "applyOrderBy");
|
|
19886
|
+
function restoreEntitiesFromLocalFilter(ents) {
|
|
19887
|
+
return ents.map((entity) => {
|
|
19888
|
+
forEach(entity, (val, key) => {
|
|
19889
|
+
var _a;
|
|
19890
|
+
if ((_a = key.startsWith) == null ? void 0 : _a.call(key, "___original___")) {
|
|
19891
|
+
entity[key.slice("___original___".length)] = val;
|
|
19892
|
+
delete entity[key];
|
|
19893
|
+
}
|
|
19894
|
+
});
|
|
19895
|
+
return entity;
|
|
19896
|
+
});
|
|
19897
|
+
}
|
|
19898
|
+
__name(restoreEntitiesFromLocalFilter, "restoreEntitiesFromLocalFilter");
|
|
19795
19899
|
function initializeHasuraWhereAndFilter(additionalFilter, where = {}, currentParams) {
|
|
19796
19900
|
where._and = where._and || [];
|
|
19797
19901
|
where._or = where._or || [];
|
|
19798
19902
|
if (typeof additionalFilter === "function") {
|
|
19799
19903
|
const newWhere = additionalFilter(where, currentParams);
|
|
19800
19904
|
if (newWhere) {
|
|
19801
|
-
|
|
19905
|
+
Object.assign(where, newWhere);
|
|
19802
19906
|
}
|
|
19803
19907
|
} else if (typeof additionalFilter === "object")
|
|
19804
19908
|
where._and.push(additionalFilter);
|
|
19805
19909
|
}
|
|
19806
19910
|
__name(initializeHasuraWhereAndFilter, "initializeHasuraWhereAndFilter");
|
|
19807
|
-
const addCustomColumnFilters = /* @__PURE__ */ __name((where, fields, currentParams) => {
|
|
19808
|
-
fields.forEach((field) => {
|
|
19809
|
-
const { customColumnFilter, filterDisabled } = field;
|
|
19810
|
-
if (filterDisabled || !customColumnFilter) return;
|
|
19811
|
-
customColumnFilter(where, currentParams);
|
|
19812
|
-
});
|
|
19813
|
-
}, "addCustomColumnFilters");
|
|
19814
19911
|
const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
|
|
19815
19912
|
function safeStringify(val) {
|
|
19816
19913
|
if (val !== null && typeof val === "object") {
|
|
@@ -19985,9 +20082,22 @@ function makeDataTableHandlers({
|
|
|
19985
20082
|
};
|
|
19986
20083
|
}
|
|
19987
20084
|
__name(makeDataTableHandlers, "makeDataTableHandlers");
|
|
20085
|
+
function cleanupFilters({ filters, ccFields }) {
|
|
20086
|
+
(filters || []).forEach((filter2) => {
|
|
20087
|
+
const { filterOn, filterValue } = filter2;
|
|
20088
|
+
const field = ccFields[filterOn];
|
|
20089
|
+
if (field.type === "number" || field.type === "integer") {
|
|
20090
|
+
filter2.filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
20091
|
+
}
|
|
20092
|
+
if (filter2.selectedFilter === "inList" && typeof filter2.filterValue === "number") {
|
|
20093
|
+
filter2.filterValue = filter2.filterValue.toString();
|
|
20094
|
+
}
|
|
20095
|
+
});
|
|
20096
|
+
}
|
|
20097
|
+
__name(cleanupFilters, "cleanupFilters");
|
|
19988
20098
|
function getQueryParams({
|
|
19989
20099
|
currentParams,
|
|
19990
|
-
|
|
20100
|
+
urlConnected,
|
|
19991
20101
|
defaults,
|
|
19992
20102
|
schema,
|
|
19993
20103
|
isInfinite,
|
|
@@ -19996,88 +20106,145 @@ function getQueryParams({
|
|
|
19996
20106
|
additionalFilter,
|
|
19997
20107
|
doNotCoercePageSize,
|
|
19998
20108
|
noOrderError,
|
|
19999
|
-
|
|
20109
|
+
isCodeModel,
|
|
20000
20110
|
ownProps
|
|
20001
20111
|
}) {
|
|
20002
|
-
|
|
20003
|
-
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
|
|
20008
|
-
let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
|
|
20009
|
-
if (page <= 0 || isNaN(page)) {
|
|
20010
|
-
page = void 0;
|
|
20011
|
-
}
|
|
20012
|
-
if (isInfinite) {
|
|
20013
|
-
page = void 0;
|
|
20014
|
-
pageSize = void 0;
|
|
20015
|
-
}
|
|
20016
|
-
if (pageSize !== void 0 && !doNotCoercePageSize) {
|
|
20017
|
-
const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
|
|
20018
|
-
(a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
|
|
20019
|
-
)[0];
|
|
20020
|
-
pageSize = closest;
|
|
20021
|
-
}
|
|
20022
|
-
const cleanedOrder = [];
|
|
20023
|
-
if (order2 && order2.length) {
|
|
20024
|
-
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20025
|
-
order2.forEach((orderVal) => {
|
|
20026
|
-
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20027
|
-
const schemaForField = ccFields[ccDisplayName];
|
|
20028
|
-
if (schemaForField) {
|
|
20029
|
-
const { path: path2 } = schemaForField;
|
|
20030
|
-
const reversed = ccDisplayName !== orderVal;
|
|
20031
|
-
const prefix2 = reversed ? "-" : "";
|
|
20032
|
-
cleanedOrder.push(prefix2 + path2);
|
|
20033
|
-
} else {
|
|
20034
|
-
!noOrderError && console.error(
|
|
20035
|
-
"No schema for field found!",
|
|
20036
|
-
ccDisplayName,
|
|
20037
|
-
JSON.stringify(schema.fields, null, 2)
|
|
20038
|
-
);
|
|
20112
|
+
let errorParsingUrlString;
|
|
20113
|
+
try {
|
|
20114
|
+
Object.keys(currentParams).forEach(function(key) {
|
|
20115
|
+
if (currentParams[key] === void 0) {
|
|
20116
|
+
delete currentParams[key];
|
|
20039
20117
|
}
|
|
20040
20118
|
});
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
|
|
20049
|
-
|
|
20050
|
-
|
|
20051
|
-
|
|
20052
|
-
pageSize
|
|
20053
|
-
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20063
|
-
|
|
20064
|
-
|
|
20065
|
-
|
|
20066
|
-
|
|
20067
|
-
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
|
|
20073
|
-
|
|
20074
|
-
|
|
20075
|
-
|
|
20076
|
-
|
|
20119
|
+
const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
|
|
20120
|
+
let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
|
|
20121
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20122
|
+
cleanupFilters({ filters, ccFields });
|
|
20123
|
+
if (page <= 0 || isNaN(page)) {
|
|
20124
|
+
page = void 0;
|
|
20125
|
+
}
|
|
20126
|
+
if (isInfinite) {
|
|
20127
|
+
page = void 0;
|
|
20128
|
+
pageSize = void 0;
|
|
20129
|
+
}
|
|
20130
|
+
if (pageSize !== void 0 && !doNotCoercePageSize) {
|
|
20131
|
+
const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
|
|
20132
|
+
(a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
|
|
20133
|
+
)[0];
|
|
20134
|
+
pageSize = closest;
|
|
20135
|
+
}
|
|
20136
|
+
const cleanedOrder = [];
|
|
20137
|
+
if (order2 && order2.length) {
|
|
20138
|
+
order2.forEach((orderVal) => {
|
|
20139
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20140
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
20141
|
+
if (schemaForField) {
|
|
20142
|
+
const { path: path2 } = schemaForField;
|
|
20143
|
+
const reversed = ccDisplayName !== orderVal;
|
|
20144
|
+
const prefix2 = reversed ? "-" : "";
|
|
20145
|
+
cleanedOrder.push(prefix2 + path2);
|
|
20146
|
+
} else {
|
|
20147
|
+
!noOrderError && console.error(
|
|
20148
|
+
"No schema for field found!",
|
|
20149
|
+
ccDisplayName,
|
|
20150
|
+
JSON.stringify(schema.fields, null, 2)
|
|
20151
|
+
);
|
|
20152
|
+
}
|
|
20153
|
+
});
|
|
20154
|
+
}
|
|
20155
|
+
let toRet = {
|
|
20156
|
+
//these are values that might be generally useful for the wrapped component
|
|
20157
|
+
page,
|
|
20158
|
+
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
20159
|
+
order: cleanedOrder,
|
|
20160
|
+
filters,
|
|
20161
|
+
searchTerm
|
|
20162
|
+
};
|
|
20163
|
+
const { where, order_by, limit, offset: offset3 } = tableQueryParamsToHasuraClauses({
|
|
20164
|
+
page,
|
|
20165
|
+
pageSize,
|
|
20166
|
+
searchTerm,
|
|
20167
|
+
filters,
|
|
20168
|
+
order: cleanedOrder,
|
|
20169
|
+
schema
|
|
20077
20170
|
});
|
|
20171
|
+
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
20172
|
+
if (isLocalCall) {
|
|
20173
|
+
const newEnts = filterLocalEntitiesToHasura(
|
|
20174
|
+
prepEntitiesForLocalFilter({ entities, ccFields }),
|
|
20175
|
+
{
|
|
20176
|
+
where,
|
|
20177
|
+
order_by: (Array.isArray(order_by) ? order_by : [order_by]).map(
|
|
20178
|
+
(obj) => {
|
|
20179
|
+
const path2 = Object.keys(obj)[0];
|
|
20180
|
+
return __spreadValues({
|
|
20181
|
+
path: path2,
|
|
20182
|
+
direction: obj[path2],
|
|
20183
|
+
ownProps
|
|
20184
|
+
}, ccFields[path2]);
|
|
20185
|
+
}
|
|
20186
|
+
),
|
|
20187
|
+
limit,
|
|
20188
|
+
offset: offset3,
|
|
20189
|
+
isInfinite
|
|
20190
|
+
}
|
|
20191
|
+
);
|
|
20192
|
+
toRet = __spreadValues(__spreadValues({}, toRet), newEnts);
|
|
20193
|
+
return toRet;
|
|
20194
|
+
} else {
|
|
20195
|
+
if (!order_by.length) {
|
|
20196
|
+
order_by.push({ updatedAt: "desc" });
|
|
20197
|
+
}
|
|
20198
|
+
order_by.push(
|
|
20199
|
+
isCodeModel ? { code: "desc" } : { [window.__sortId || "id"]: "desc" }
|
|
20200
|
+
);
|
|
20201
|
+
return __spreadProps(__spreadValues({}, toRet), {
|
|
20202
|
+
variables: {
|
|
20203
|
+
where,
|
|
20204
|
+
order_by,
|
|
20205
|
+
limit,
|
|
20206
|
+
offset: offset3
|
|
20207
|
+
}
|
|
20208
|
+
});
|
|
20209
|
+
}
|
|
20210
|
+
} catch (e) {
|
|
20211
|
+
if (urlConnected) {
|
|
20212
|
+
errorParsingUrlString = e;
|
|
20213
|
+
console.error(
|
|
20214
|
+
"The following error occurred when trying to build the query params. This is probably due to a malformed URL:",
|
|
20215
|
+
e
|
|
20216
|
+
);
|
|
20217
|
+
return {
|
|
20218
|
+
errorParsingUrlString,
|
|
20219
|
+
variables: {
|
|
20220
|
+
where: {},
|
|
20221
|
+
order_by: [],
|
|
20222
|
+
limit: 0,
|
|
20223
|
+
offset: 0
|
|
20224
|
+
}
|
|
20225
|
+
};
|
|
20226
|
+
} else {
|
|
20227
|
+
console.error("Error building query params from filter:");
|
|
20228
|
+
throw e;
|
|
20229
|
+
}
|
|
20078
20230
|
}
|
|
20079
20231
|
}
|
|
20080
20232
|
__name(getQueryParams, "getQueryParams");
|
|
20233
|
+
function prepEntitiesForLocalFilter({ entities, ccFields }) {
|
|
20234
|
+
const r2 = entities.map((entity) => {
|
|
20235
|
+
const newEnt = __spreadValues({}, entity);
|
|
20236
|
+
forEach(ccFields, ({ getValueToFilterOn, path: path2 }) => {
|
|
20237
|
+
if (getValueToFilterOn) {
|
|
20238
|
+
newEnt["___original___" + path2] = newEnt[path2];
|
|
20239
|
+
const value = getValueToFilterOn(newEnt);
|
|
20240
|
+
newEnt[path2] = value;
|
|
20241
|
+
}
|
|
20242
|
+
});
|
|
20243
|
+
return newEnt;
|
|
20244
|
+
});
|
|
20245
|
+
return r2;
|
|
20246
|
+
}
|
|
20247
|
+
__name(prepEntitiesForLocalFilter, "prepEntitiesForLocalFilter");
|
|
20081
20248
|
function PagingInput({ disabled, onBlur, defaultPage }) {
|
|
20082
20249
|
const [page, setPage] = React.useState(defaultPage);
|
|
20083
20250
|
const defaultValue2 = React.useRef(defaultPage);
|
|
@@ -31881,7 +32048,15 @@ function requireColor() {
|
|
|
31881
32048
|
__name(requireColor, "requireColor");
|
|
31882
32049
|
var colorExports = requireColor();
|
|
31883
32050
|
const Color = /* @__PURE__ */ getDefaultExportFromCjs(colorExports);
|
|
31884
|
-
|
|
32051
|
+
function determineBlackOrWhiteTextColor(c2) {
|
|
32052
|
+
try {
|
|
32053
|
+
return Color(c2).isLight() ? "#000000" : "#FFFFFF";
|
|
32054
|
+
} catch (e) {
|
|
32055
|
+
console.error("Error in color parsing:", e);
|
|
32056
|
+
return "#000000";
|
|
32057
|
+
}
|
|
32058
|
+
}
|
|
32059
|
+
__name(determineBlackOrWhiteTextColor, "determineBlackOrWhiteTextColor");
|
|
31885
32060
|
function getTagsAndTagOptions(allTags) {
|
|
31886
32061
|
return flatMap(allTags, (tag) => {
|
|
31887
32062
|
if (tag.tagOptions && tag.tagOptions.length) {
|
|
@@ -51204,7 +51379,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
|
|
|
51204
51379
|
if (order2 && order2.length) {
|
|
51205
51380
|
order2.forEach((order22) => {
|
|
51206
51381
|
const orderField = order22.replace("-", "");
|
|
51207
|
-
if (orderField ===
|
|
51382
|
+
if (orderField === path2) {
|
|
51208
51383
|
if (orderField === order22) {
|
|
51209
51384
|
ordering = "asc";
|
|
51210
51385
|
} else {
|
|
@@ -56295,6 +56470,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
56295
56470
|
doNotCoercePageSize,
|
|
56296
56471
|
currentParams,
|
|
56297
56472
|
entities: props.entities,
|
|
56473
|
+
// for local table
|
|
56474
|
+
urlConnected,
|
|
56298
56475
|
defaults,
|
|
56299
56476
|
schema: convertedSchema,
|
|
56300
56477
|
isInfinite,
|
|
@@ -58687,7 +58864,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58687
58864
|
try {
|
|
58688
58865
|
const allEntities = yield safeQuery(fragment, {
|
|
58689
58866
|
variables: {
|
|
58690
|
-
|
|
58867
|
+
where: variables.where,
|
|
58691
58868
|
sort: variables.sort
|
|
58692
58869
|
},
|
|
58693
58870
|
canCancel: true
|
|
@@ -69067,6 +69244,7 @@ function parseCsvOrExcelFile(_0) {
|
|
|
69067
69244
|
}
|
|
69068
69245
|
__name(parseCsvOrExcelFile, "parseCsvOrExcelFile");
|
|
69069
69246
|
const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(exports, null, function* () {
|
|
69247
|
+
var _a, _b, _c, _d;
|
|
69070
69248
|
if (!file || Array.isArray(file) && !file.length) return [];
|
|
69071
69249
|
const zipExtracted = yield extractZipFiles(file);
|
|
69072
69250
|
const acceptedFiles = [];
|
|
@@ -69076,9 +69254,12 @@ const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(expo
|
|
|
69076
69254
|
}
|
|
69077
69255
|
}
|
|
69078
69256
|
if (acceptedFiles.length && acceptedFiles.length < zipExtracted.length)
|
|
69079
|
-
window.toastr.warning
|
|
69257
|
+
(_b = (_a = window == null ? void 0 : window.toastr) == null ? void 0 : _a.warning) == null ? void 0 : _b.call(
|
|
69258
|
+
_a,
|
|
69259
|
+
"Some files don't have the proper file extension."
|
|
69260
|
+
);
|
|
69080
69261
|
if (!acceptedFiles.length)
|
|
69081
|
-
window.toastr.warning("No files with the proper extension were found.");
|
|
69262
|
+
(_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.");
|
|
69082
69263
|
return acceptedFiles;
|
|
69083
69264
|
}), "filterFilesInZip");
|
|
69084
69265
|
function removeExt(filename) {
|
|
@@ -71806,12 +71987,15 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71806
71987
|
doNotCoercePageSize,
|
|
71807
71988
|
currentParams,
|
|
71808
71989
|
entities,
|
|
71990
|
+
// for local table
|
|
71991
|
+
urlConnected,
|
|
71809
71992
|
defaults: defaultsToUse,
|
|
71810
71993
|
schema: convertedSchema,
|
|
71811
71994
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71812
71995
|
isLocalCall,
|
|
71813
71996
|
additionalFilter,
|
|
71814
71997
|
noOrderError,
|
|
71998
|
+
isCodeModel,
|
|
71815
71999
|
ownProps: passingProps
|
|
71816
72000
|
});
|
|
71817
72001
|
}, [
|
|
@@ -77970,6 +78154,7 @@ exports.createDynamicBarMenu = createDynamicBarMenu;
|
|
|
77970
78154
|
exports.createDynamicMenu = createDynamicMenu;
|
|
77971
78155
|
exports.createMenu = createMenu;
|
|
77972
78156
|
exports.designIcon = designIcon;
|
|
78157
|
+
exports.determineBlackOrWhiteTextColor = determineBlackOrWhiteTextColor;
|
|
77973
78158
|
exports.dnaIcon = dnaIcon;
|
|
77974
78159
|
exports.doesSearchValMatchText = doesSearchValMatchText;
|
|
77975
78160
|
exports.driveIcon = driveIcon;
|
package/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { default as IntentText } from './IntentText';
|
|
|
33
33
|
export { default as popoverOverflowModifiers } from './utils/popoverOverflowModifiers';
|
|
34
34
|
export { default as tgFormValues } from './utils/tgFormValues';
|
|
35
35
|
export { default as withStore } from './utils/withStore';
|
|
36
|
+
export { default as determineBlackOrWhiteTextColor } from './utils/determineBlackOrWhiteTextColor';
|
|
36
37
|
export { default as InfoHelper } from './InfoHelper';
|
|
37
38
|
export { default as showConfirmationDialog } from './showConfirmationDialog';
|
|
38
39
|
export { default as showAppSpinner } from './showAppSpinner';
|