@teselagen/ui 0.8.6-beta.2 → 0.8.6-beta.20
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 +311 -127
- package/index.d.ts +1 -0
- package/index.es.js +311 -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 +127 -8
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +653 -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.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';
|
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,110 @@ 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
|
+
orderFuncs.push((r2) => {
|
|
19800
|
+
const val = fn4(r2);
|
|
19801
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19802
|
+
});
|
|
19803
|
+
ascOrDescArray.push("desc");
|
|
19804
|
+
orderFuncs.push(fn4);
|
|
19805
|
+
ascOrDescArray.push(direction);
|
|
19806
|
+
});
|
|
19807
|
+
} else if (getValueToFilterOn) {
|
|
19808
|
+
orderFuncs.push((r2) => {
|
|
19809
|
+
const val = getValueToFilterOn(r2, ownProps);
|
|
19810
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19811
|
+
});
|
|
19812
|
+
ascOrDescArray.push("desc");
|
|
19813
|
+
orderFuncs.push((r2) => getValueToFilterOn(r2, ownProps));
|
|
19814
|
+
ascOrDescArray.push(direction);
|
|
19815
|
+
} else if (type2 === "timestamp") {
|
|
19816
|
+
orderFuncs.push((r2) => {
|
|
19817
|
+
const val = get$3(r2, path2);
|
|
19818
|
+
return val ? 1 : 0;
|
|
19819
|
+
});
|
|
19820
|
+
ascOrDescArray.push("desc");
|
|
19821
|
+
orderFuncs.push((r2) => {
|
|
19822
|
+
const val = get$3(r2, path2);
|
|
19823
|
+
return val ? new Date(val).getTime() : -Infinity;
|
|
19824
|
+
});
|
|
19825
|
+
ascOrDescArray.push(direction);
|
|
19826
|
+
} else if (path2 && endsWith$1(path2.toLowerCase(), "id")) {
|
|
19827
|
+
orderFuncs.push((r2) => {
|
|
19828
|
+
const val = get$3(r2, path2);
|
|
19829
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19830
|
+
});
|
|
19831
|
+
ascOrDescArray.push("desc");
|
|
19832
|
+
orderFuncs.push((o2) => {
|
|
19833
|
+
const val = get$3(o2, path2);
|
|
19834
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19835
|
+
return parseInt(val, 10) || 0;
|
|
19836
|
+
});
|
|
19837
|
+
ascOrDescArray.push(direction);
|
|
19838
|
+
} else {
|
|
19839
|
+
orderFuncs.push((r2) => {
|
|
19840
|
+
const val = get$3(r2, path2);
|
|
19841
|
+
return val !== null && val !== void 0 ? 1 : 0;
|
|
19842
|
+
});
|
|
19843
|
+
ascOrDescArray.push("desc");
|
|
19844
|
+
orderFuncs.push((r2) => {
|
|
19845
|
+
const val = get$3(r2, path2);
|
|
19846
|
+
if (val === null || val === void 0) return -Infinity;
|
|
19847
|
+
if (isString$1(val)) {
|
|
19848
|
+
return val.toLowerCase().replace(
|
|
19849
|
+
/(\d+)/g,
|
|
19850
|
+
(num) => (
|
|
19851
|
+
// Pad numbers with leading zeros for proper natural sort
|
|
19852
|
+
num.padStart(10, "0")
|
|
19853
|
+
)
|
|
19854
|
+
);
|
|
19855
|
+
}
|
|
19856
|
+
return val;
|
|
19857
|
+
});
|
|
19858
|
+
ascOrDescArray.push(direction);
|
|
19859
|
+
}
|
|
19860
|
+
}
|
|
19861
|
+
);
|
|
19862
|
+
records = orderBy$1(records, orderFuncs, ascOrDescArray);
|
|
19773
19863
|
}
|
|
19774
19864
|
return records;
|
|
19775
19865
|
}
|
|
19776
19866
|
__name(applyOrderBy, "applyOrderBy");
|
|
19867
|
+
function restoreEntitiesFromLocalFilter(ents) {
|
|
19868
|
+
return ents.map((entity) => {
|
|
19869
|
+
forEach(entity, (val, key) => {
|
|
19870
|
+
var _a;
|
|
19871
|
+
if ((_a = key.startsWith) == null ? void 0 : _a.call(key, "___original___")) {
|
|
19872
|
+
entity[key.slice("___original___".length)] = val;
|
|
19873
|
+
delete entity[key];
|
|
19874
|
+
}
|
|
19875
|
+
});
|
|
19876
|
+
return entity;
|
|
19877
|
+
});
|
|
19878
|
+
}
|
|
19879
|
+
__name(restoreEntitiesFromLocalFilter, "restoreEntitiesFromLocalFilter");
|
|
19777
19880
|
function initializeHasuraWhereAndFilter(additionalFilter, where = {}, currentParams) {
|
|
19778
19881
|
where._and = where._and || [];
|
|
19779
19882
|
where._or = where._or || [];
|
|
19780
19883
|
if (typeof additionalFilter === "function") {
|
|
19781
19884
|
const newWhere = additionalFilter(where, currentParams);
|
|
19782
19885
|
if (newWhere) {
|
|
19783
|
-
|
|
19886
|
+
Object.assign(where, newWhere);
|
|
19784
19887
|
}
|
|
19785
19888
|
} else if (typeof additionalFilter === "object")
|
|
19786
19889
|
where._and.push(additionalFilter);
|
|
19787
19890
|
}
|
|
19788
19891
|
__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
19892
|
const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
|
|
19797
19893
|
function safeStringify(val) {
|
|
19798
19894
|
if (val !== null && typeof val === "object") {
|
|
@@ -19967,9 +20063,22 @@ function makeDataTableHandlers({
|
|
|
19967
20063
|
};
|
|
19968
20064
|
}
|
|
19969
20065
|
__name(makeDataTableHandlers, "makeDataTableHandlers");
|
|
20066
|
+
function cleanupFilters({ filters, ccFields }) {
|
|
20067
|
+
(filters || []).forEach((filter2) => {
|
|
20068
|
+
const { filterOn, filterValue } = filter2;
|
|
20069
|
+
const field = ccFields[filterOn];
|
|
20070
|
+
if (field.type === "number" || field.type === "integer") {
|
|
20071
|
+
filter2.filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
20072
|
+
}
|
|
20073
|
+
if (filter2.selectedFilter === "inList" && typeof filter2.filterValue === "number") {
|
|
20074
|
+
filter2.filterValue = filter2.filterValue.toString();
|
|
20075
|
+
}
|
|
20076
|
+
});
|
|
20077
|
+
}
|
|
20078
|
+
__name(cleanupFilters, "cleanupFilters");
|
|
19970
20079
|
function getQueryParams({
|
|
19971
20080
|
currentParams,
|
|
19972
|
-
|
|
20081
|
+
urlConnected,
|
|
19973
20082
|
defaults,
|
|
19974
20083
|
schema,
|
|
19975
20084
|
isInfinite,
|
|
@@ -19978,88 +20087,145 @@ function getQueryParams({
|
|
|
19978
20087
|
additionalFilter,
|
|
19979
20088
|
doNotCoercePageSize,
|
|
19980
20089
|
noOrderError,
|
|
19981
|
-
|
|
20090
|
+
isCodeModel,
|
|
19982
20091
|
ownProps
|
|
19983
20092
|
}) {
|
|
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
|
-
);
|
|
20093
|
+
let errorParsingUrlString;
|
|
20094
|
+
try {
|
|
20095
|
+
Object.keys(currentParams).forEach(function(key) {
|
|
20096
|
+
if (currentParams[key] === void 0) {
|
|
20097
|
+
delete currentParams[key];
|
|
20021
20098
|
}
|
|
20022
20099
|
});
|
|
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
|
-
|
|
20100
|
+
const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
|
|
20101
|
+
let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
|
|
20102
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
20103
|
+
cleanupFilters({ filters, ccFields });
|
|
20104
|
+
if (page <= 0 || isNaN(page)) {
|
|
20105
|
+
page = void 0;
|
|
20106
|
+
}
|
|
20107
|
+
if (isInfinite) {
|
|
20108
|
+
page = void 0;
|
|
20109
|
+
pageSize = void 0;
|
|
20110
|
+
}
|
|
20111
|
+
if (pageSize !== void 0 && !doNotCoercePageSize) {
|
|
20112
|
+
const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
|
|
20113
|
+
(a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
|
|
20114
|
+
)[0];
|
|
20115
|
+
pageSize = closest;
|
|
20116
|
+
}
|
|
20117
|
+
const cleanedOrder = [];
|
|
20118
|
+
if (order2 && order2.length) {
|
|
20119
|
+
order2.forEach((orderVal) => {
|
|
20120
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
20121
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
20122
|
+
if (schemaForField) {
|
|
20123
|
+
const { path: path2 } = schemaForField;
|
|
20124
|
+
const reversed = ccDisplayName !== orderVal;
|
|
20125
|
+
const prefix2 = reversed ? "-" : "";
|
|
20126
|
+
cleanedOrder.push(prefix2 + path2);
|
|
20127
|
+
} else {
|
|
20128
|
+
!noOrderError && console.error(
|
|
20129
|
+
"No schema for field found!",
|
|
20130
|
+
ccDisplayName,
|
|
20131
|
+
JSON.stringify(schema.fields, null, 2)
|
|
20132
|
+
);
|
|
20133
|
+
}
|
|
20134
|
+
});
|
|
20135
|
+
}
|
|
20136
|
+
let toRet = {
|
|
20137
|
+
//these are values that might be generally useful for the wrapped component
|
|
20138
|
+
page,
|
|
20139
|
+
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
20140
|
+
order: cleanedOrder,
|
|
20141
|
+
filters,
|
|
20142
|
+
searchTerm
|
|
20143
|
+
};
|
|
20144
|
+
const { where, order_by, limit, offset: offset3 } = tableQueryParamsToHasuraClauses({
|
|
20145
|
+
page,
|
|
20146
|
+
pageSize,
|
|
20147
|
+
searchTerm,
|
|
20148
|
+
filters,
|
|
20149
|
+
order: cleanedOrder,
|
|
20150
|
+
schema
|
|
20059
20151
|
});
|
|
20152
|
+
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
20153
|
+
if (isLocalCall) {
|
|
20154
|
+
const newEnts = filterLocalEntitiesToHasura(
|
|
20155
|
+
prepEntitiesForLocalFilter({ entities, ccFields }),
|
|
20156
|
+
{
|
|
20157
|
+
where,
|
|
20158
|
+
order_by: (Array.isArray(order_by) ? order_by : [order_by]).map(
|
|
20159
|
+
(obj) => {
|
|
20160
|
+
const path2 = Object.keys(obj)[0];
|
|
20161
|
+
return __spreadValues({
|
|
20162
|
+
path: path2,
|
|
20163
|
+
direction: obj[path2],
|
|
20164
|
+
ownProps
|
|
20165
|
+
}, ccFields[path2]);
|
|
20166
|
+
}
|
|
20167
|
+
),
|
|
20168
|
+
limit,
|
|
20169
|
+
offset: offset3,
|
|
20170
|
+
isInfinite
|
|
20171
|
+
}
|
|
20172
|
+
);
|
|
20173
|
+
toRet = __spreadValues(__spreadValues({}, toRet), newEnts);
|
|
20174
|
+
return toRet;
|
|
20175
|
+
} else {
|
|
20176
|
+
if (!order_by.length) {
|
|
20177
|
+
order_by.push({ updatedAt: "desc" });
|
|
20178
|
+
}
|
|
20179
|
+
order_by.push(
|
|
20180
|
+
isCodeModel ? { code: "desc" } : { [window.__sortId || "id"]: "desc" }
|
|
20181
|
+
);
|
|
20182
|
+
return __spreadProps(__spreadValues({}, toRet), {
|
|
20183
|
+
variables: {
|
|
20184
|
+
where,
|
|
20185
|
+
order_by,
|
|
20186
|
+
limit,
|
|
20187
|
+
offset: offset3
|
|
20188
|
+
}
|
|
20189
|
+
});
|
|
20190
|
+
}
|
|
20191
|
+
} catch (e) {
|
|
20192
|
+
if (urlConnected) {
|
|
20193
|
+
errorParsingUrlString = e;
|
|
20194
|
+
console.error(
|
|
20195
|
+
"The following error occurred when trying to build the query params. This is probably due to a malformed URL:",
|
|
20196
|
+
e
|
|
20197
|
+
);
|
|
20198
|
+
return {
|
|
20199
|
+
errorParsingUrlString,
|
|
20200
|
+
variables: {
|
|
20201
|
+
where: {},
|
|
20202
|
+
order_by: [],
|
|
20203
|
+
limit: 0,
|
|
20204
|
+
offset: 0
|
|
20205
|
+
}
|
|
20206
|
+
};
|
|
20207
|
+
} else {
|
|
20208
|
+
console.error("Error building query params from filter:");
|
|
20209
|
+
throw e;
|
|
20210
|
+
}
|
|
20060
20211
|
}
|
|
20061
20212
|
}
|
|
20062
20213
|
__name(getQueryParams, "getQueryParams");
|
|
20214
|
+
function prepEntitiesForLocalFilter({ entities, ccFields }) {
|
|
20215
|
+
const r2 = entities.map((entity) => {
|
|
20216
|
+
const newEnt = __spreadValues({}, entity);
|
|
20217
|
+
forEach(ccFields, ({ getValueToFilterOn, path: path2 }) => {
|
|
20218
|
+
if (getValueToFilterOn) {
|
|
20219
|
+
newEnt["___original___" + path2] = newEnt[path2];
|
|
20220
|
+
const value = getValueToFilterOn(newEnt);
|
|
20221
|
+
newEnt[path2] = value;
|
|
20222
|
+
}
|
|
20223
|
+
});
|
|
20224
|
+
return newEnt;
|
|
20225
|
+
});
|
|
20226
|
+
return r2;
|
|
20227
|
+
}
|
|
20228
|
+
__name(prepEntitiesForLocalFilter, "prepEntitiesForLocalFilter");
|
|
20063
20229
|
function PagingInput({ disabled, onBlur, defaultPage }) {
|
|
20064
20230
|
const [page, setPage] = useState(defaultPage);
|
|
20065
20231
|
const defaultValue2 = useRef(defaultPage);
|
|
@@ -31863,7 +32029,15 @@ function requireColor() {
|
|
|
31863
32029
|
__name(requireColor, "requireColor");
|
|
31864
32030
|
var colorExports = requireColor();
|
|
31865
32031
|
const Color = /* @__PURE__ */ getDefaultExportFromCjs(colorExports);
|
|
31866
|
-
|
|
32032
|
+
function determineBlackOrWhiteTextColor(c2) {
|
|
32033
|
+
try {
|
|
32034
|
+
return Color(c2).isLight() ? "#000000" : "#FFFFFF";
|
|
32035
|
+
} catch (e) {
|
|
32036
|
+
console.error("Error in color parsing:", e);
|
|
32037
|
+
return "#000000";
|
|
32038
|
+
}
|
|
32039
|
+
}
|
|
32040
|
+
__name(determineBlackOrWhiteTextColor, "determineBlackOrWhiteTextColor");
|
|
31867
32041
|
function getTagsAndTagOptions(allTags) {
|
|
31868
32042
|
return flatMap(allTags, (tag) => {
|
|
31869
32043
|
if (tag.tagOptions && tag.tagOptions.length) {
|
|
@@ -51186,7 +51360,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
|
|
|
51186
51360
|
if (order2 && order2.length) {
|
|
51187
51361
|
order2.forEach((order22) => {
|
|
51188
51362
|
const orderField = order22.replace("-", "");
|
|
51189
|
-
if (orderField ===
|
|
51363
|
+
if (orderField === path2) {
|
|
51190
51364
|
if (orderField === order22) {
|
|
51191
51365
|
ordering = "asc";
|
|
51192
51366
|
} else {
|
|
@@ -56277,6 +56451,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
56277
56451
|
doNotCoercePageSize,
|
|
56278
56452
|
currentParams,
|
|
56279
56453
|
entities: props.entities,
|
|
56454
|
+
// for local table
|
|
56455
|
+
urlConnected,
|
|
56280
56456
|
defaults,
|
|
56281
56457
|
schema: convertedSchema,
|
|
56282
56458
|
isInfinite,
|
|
@@ -58669,7 +58845,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
58669
58845
|
try {
|
|
58670
58846
|
const allEntities = yield safeQuery(fragment, {
|
|
58671
58847
|
variables: {
|
|
58672
|
-
|
|
58848
|
+
where: variables.where,
|
|
58673
58849
|
sort: variables.sort
|
|
58674
58850
|
},
|
|
58675
58851
|
canCancel: true
|
|
@@ -69049,6 +69225,7 @@ function parseCsvOrExcelFile(_0) {
|
|
|
69049
69225
|
}
|
|
69050
69226
|
__name(parseCsvOrExcelFile, "parseCsvOrExcelFile");
|
|
69051
69227
|
const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(void 0, null, function* () {
|
|
69228
|
+
var _a, _b, _c, _d;
|
|
69052
69229
|
if (!file || Array.isArray(file) && !file.length) return [];
|
|
69053
69230
|
const zipExtracted = yield extractZipFiles(file);
|
|
69054
69231
|
const acceptedFiles = [];
|
|
@@ -69058,9 +69235,12 @@ const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(void
|
|
|
69058
69235
|
}
|
|
69059
69236
|
}
|
|
69060
69237
|
if (acceptedFiles.length && acceptedFiles.length < zipExtracted.length)
|
|
69061
|
-
window.toastr.warning
|
|
69238
|
+
(_b = (_a = window == null ? void 0 : window.toastr) == null ? void 0 : _a.warning) == null ? void 0 : _b.call(
|
|
69239
|
+
_a,
|
|
69240
|
+
"Some files don't have the proper file extension."
|
|
69241
|
+
);
|
|
69062
69242
|
if (!acceptedFiles.length)
|
|
69063
|
-
window.toastr.warning("No files with the proper extension were found.");
|
|
69243
|
+
(_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
69244
|
return acceptedFiles;
|
|
69065
69245
|
}), "filterFilesInZip");
|
|
69066
69246
|
function removeExt(filename) {
|
|
@@ -71788,12 +71968,15 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71788
71968
|
doNotCoercePageSize,
|
|
71789
71969
|
currentParams,
|
|
71790
71970
|
entities,
|
|
71971
|
+
// for local table
|
|
71972
|
+
urlConnected,
|
|
71791
71973
|
defaults: defaultsToUse,
|
|
71792
71974
|
schema: convertedSchema,
|
|
71793
71975
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71794
71976
|
isLocalCall,
|
|
71795
71977
|
additionalFilter,
|
|
71796
71978
|
noOrderError,
|
|
71979
|
+
isCodeModel,
|
|
71797
71980
|
ownProps: passingProps
|
|
71798
71981
|
});
|
|
71799
71982
|
}, [
|
|
@@ -77953,6 +78136,7 @@ export {
|
|
|
77953
78136
|
createDynamicMenu,
|
|
77954
78137
|
createMenu,
|
|
77955
78138
|
designIcon,
|
|
78139
|
+
determineBlackOrWhiteTextColor,
|
|
77956
78140
|
dnaIcon,
|
|
77957
78141
|
doesSearchValMatchText,
|
|
77958
78142
|
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
|