@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.
@@ -1,2 +1 @@
1
1
  export function initializeHasuraWhereAndFilter(additionalFilter: any, where: {} | undefined, currentParams: any): void;
2
- export function addCustomColumnFilters(where: any, fields: any, currentParams: any): void;
@@ -19,8 +19,9 @@ export function makeDataTableHandlers({ setNewParams, defaults, onlyOneFilter }:
19
19
  setOrder: (order: any, isRemove: any, shiftHeld: any) => any;
20
20
  setNewParams: any;
21
21
  };
22
- export function getQueryParams({ currentParams, defaults, schema, isInfinite, entities, isLocalCall, additionalFilter, doNotCoercePageSize, noOrderError, ownProps }: {
22
+ export function getQueryParams({ currentParams, urlConnected, defaults, schema, isInfinite, entities, isLocalCall, additionalFilter, doNotCoercePageSize, noOrderError, isCodeModel, ownProps }: {
23
23
  currentParams: any;
24
+ urlConnected: any;
24
25
  defaults: any;
25
26
  schema: any;
26
27
  isInfinite: any;
@@ -29,6 +30,7 @@ export function getQueryParams({ currentParams, defaults, schema, isInfinite, en
29
30
  additionalFilter: any;
30
31
  doNotCoercePageSize: any;
31
32
  noOrderError: any;
33
+ isCodeModel: any;
32
34
  ownProps: any;
33
35
  }): {
34
36
  page: any;
@@ -39,7 +41,7 @@ export function getQueryParams({ currentParams, defaults, schema, isInfinite, en
39
41
  } | {
40
42
  variables: {
41
43
  where: {};
42
- order_by: {};
44
+ order_by: any[];
43
45
  limit: any;
44
46
  offset: number;
45
47
  };
@@ -48,5 +50,14 @@ export function getQueryParams({ currentParams, defaults, schema, isInfinite, en
48
50
  order: any[];
49
51
  filters: any;
50
52
  searchTerm: any;
53
+ errorParsingUrlString?: undefined;
54
+ } | {
55
+ errorParsingUrlString: unknown;
56
+ variables: {
57
+ where: {};
58
+ order_by: never[];
59
+ limit: number;
60
+ offset: number;
61
+ };
51
62
  };
52
63
  export const defaultPageSizes: number[];
@@ -8,7 +8,7 @@ export function tableQueryParamsToHasuraClauses({ page, pageSize, searchTerm, fi
8
8
  additionalFilter: any;
9
9
  }): {
10
10
  where: {};
11
- order_by: {};
11
+ order_by: any[];
12
12
  limit: any;
13
13
  offset: number;
14
14
  };
package/README.md CHANGED
@@ -4,7 +4,7 @@ This library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  ## Running unit tests
6
6
 
7
- Run `nx test ui` to execute the unit tests via [Vitest](https://vitest.dev/).
7
+ Run `nx test ui` to execute the unit tests via bun test
8
8
 
9
9
  ## Installation (react)
10
10
 
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
- const filterValue = searchTerm;
19427
- if (type2 === "string" || type2 === "lookup") {
19428
- const o2 = set$1({}, path2, { _ilike: `%${filterValue}%` });
19429
- searchTermFilters.push(o2);
19430
- } else if (type2 === "boolean") {
19431
- let regex;
19432
- try {
19433
- regex = new RegExp("^" + searchTerm, "ig");
19434
- } catch (error) {
19435
- }
19436
- if (regex) {
19437
- if ("true".replace(regex, "") !== "true") {
19438
- const o2 = set$1({}, path2, { _eq: true });
19439
- searchTermFilters.push(o2);
19440
- } else if ("false".replace(regex, "") !== "false") {
19441
- const o2 = set$1({}, path2, { _eq: false });
19442
- searchTermFilters.push(o2);
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
- } else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
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]: { _not_ilike: `%${filterValue}%` } };
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] = direction;
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[key];
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,110 @@ function applyWhereClause(records, where) {
19782
19803
  return records.filter((record) => applyFilter(record, where));
19783
19804
  }
19784
19805
  __name(applyWhereClause, "applyWhereClause");
19785
- function applyOrderBy(records, order_by) {
19786
- const keys2 = Object.keys(order_by);
19787
- if (keys2.length > 0) {
19788
- const field = keys2[0];
19789
- const direction = order_by[field] === "asc" ? "asc" : "desc";
19790
- return orderBy$1(records, [field], [direction]);
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
+ orderFuncs.push((r2) => {
19818
+ const val = fn4(r2);
19819
+ return val !== null && val !== void 0 ? 1 : 0;
19820
+ });
19821
+ ascOrDescArray.push("desc");
19822
+ orderFuncs.push(fn4);
19823
+ ascOrDescArray.push(direction);
19824
+ });
19825
+ } else if (getValueToFilterOn) {
19826
+ orderFuncs.push((r2) => {
19827
+ const val = getValueToFilterOn(r2, ownProps);
19828
+ return val !== null && val !== void 0 ? 1 : 0;
19829
+ });
19830
+ ascOrDescArray.push("desc");
19831
+ orderFuncs.push((r2) => getValueToFilterOn(r2, ownProps));
19832
+ ascOrDescArray.push(direction);
19833
+ } else if (type2 === "timestamp") {
19834
+ orderFuncs.push((r2) => {
19835
+ const val = get$3(r2, path2);
19836
+ return val ? 1 : 0;
19837
+ });
19838
+ ascOrDescArray.push("desc");
19839
+ orderFuncs.push((r2) => {
19840
+ const val = get$3(r2, path2);
19841
+ return val ? new Date(val).getTime() : -Infinity;
19842
+ });
19843
+ ascOrDescArray.push(direction);
19844
+ } else if (path2 && endsWith$1(path2.toLowerCase(), "id")) {
19845
+ orderFuncs.push((r2) => {
19846
+ const val = get$3(r2, path2);
19847
+ return val !== null && val !== void 0 ? 1 : 0;
19848
+ });
19849
+ ascOrDescArray.push("desc");
19850
+ orderFuncs.push((o2) => {
19851
+ const val = get$3(o2, path2);
19852
+ if (val === null || val === void 0) return -Infinity;
19853
+ return parseInt(val, 10) || 0;
19854
+ });
19855
+ ascOrDescArray.push(direction);
19856
+ } else {
19857
+ orderFuncs.push((r2) => {
19858
+ const val = get$3(r2, path2);
19859
+ return val !== null && val !== void 0 ? 1 : 0;
19860
+ });
19861
+ ascOrDescArray.push("desc");
19862
+ orderFuncs.push((r2) => {
19863
+ const val = get$3(r2, path2);
19864
+ if (val === null || val === void 0) return -Infinity;
19865
+ if (isString$1(val)) {
19866
+ return val.toLowerCase().replace(
19867
+ /(\d+)/g,
19868
+ (num) => (
19869
+ // Pad numbers with leading zeros for proper natural sort
19870
+ num.padStart(10, "0")
19871
+ )
19872
+ );
19873
+ }
19874
+ return val;
19875
+ });
19876
+ ascOrDescArray.push(direction);
19877
+ }
19878
+ }
19879
+ );
19880
+ records = orderBy$1(records, orderFuncs, ascOrDescArray);
19791
19881
  }
19792
19882
  return records;
19793
19883
  }
19794
19884
  __name(applyOrderBy, "applyOrderBy");
19885
+ function restoreEntitiesFromLocalFilter(ents) {
19886
+ return ents.map((entity) => {
19887
+ forEach(entity, (val, key) => {
19888
+ var _a;
19889
+ if ((_a = key.startsWith) == null ? void 0 : _a.call(key, "___original___")) {
19890
+ entity[key.slice("___original___".length)] = val;
19891
+ delete entity[key];
19892
+ }
19893
+ });
19894
+ return entity;
19895
+ });
19896
+ }
19897
+ __name(restoreEntitiesFromLocalFilter, "restoreEntitiesFromLocalFilter");
19795
19898
  function initializeHasuraWhereAndFilter(additionalFilter, where = {}, currentParams) {
19796
19899
  where._and = where._and || [];
19797
19900
  where._or = where._or || [];
19798
19901
  if (typeof additionalFilter === "function") {
19799
19902
  const newWhere = additionalFilter(where, currentParams);
19800
19903
  if (newWhere) {
19801
- where = __spreadValues(__spreadValues({}, where), newWhere);
19904
+ Object.assign(where, newWhere);
19802
19905
  }
19803
19906
  } else if (typeof additionalFilter === "object")
19804
19907
  where._and.push(additionalFilter);
19805
19908
  }
19806
19909
  __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
19910
  const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
19815
19911
  function safeStringify(val) {
19816
19912
  if (val !== null && typeof val === "object") {
@@ -19985,9 +20081,22 @@ function makeDataTableHandlers({
19985
20081
  };
19986
20082
  }
19987
20083
  __name(makeDataTableHandlers, "makeDataTableHandlers");
20084
+ function cleanupFilters({ filters, ccFields }) {
20085
+ (filters || []).forEach((filter2) => {
20086
+ const { filterOn, filterValue } = filter2;
20087
+ const field = ccFields[filterOn];
20088
+ if (field.type === "number" || field.type === "integer") {
20089
+ filter2.filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
20090
+ }
20091
+ if (filter2.selectedFilter === "inList" && typeof filter2.filterValue === "number") {
20092
+ filter2.filterValue = filter2.filterValue.toString();
20093
+ }
20094
+ });
20095
+ }
20096
+ __name(cleanupFilters, "cleanupFilters");
19988
20097
  function getQueryParams({
19989
20098
  currentParams,
19990
- // urlConnected,
20099
+ urlConnected,
19991
20100
  defaults,
19992
20101
  schema,
19993
20102
  isInfinite,
@@ -19996,88 +20105,145 @@ function getQueryParams({
19996
20105
  additionalFilter,
19997
20106
  doNotCoercePageSize,
19998
20107
  noOrderError,
19999
- // isCodeModel,
20108
+ isCodeModel,
20000
20109
  ownProps
20001
20110
  }) {
20002
- Object.keys(currentParams).forEach(function(key) {
20003
- if (currentParams[key] === void 0) {
20004
- delete currentParams[key];
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
- );
20111
+ let errorParsingUrlString;
20112
+ try {
20113
+ Object.keys(currentParams).forEach(function(key) {
20114
+ if (currentParams[key] === void 0) {
20115
+ delete currentParams[key];
20039
20116
  }
20040
20117
  });
20041
- }
20042
- let toRet = {
20043
- //these are values that might be generally useful for the wrapped component
20044
- page,
20045
- pageSize: ownProps.controlled_pageSize || pageSize,
20046
- order: cleanedOrder,
20047
- filters,
20048
- searchTerm
20049
- };
20050
- const { where, order_by, limit, offset: offset3 } = tableQueryParamsToHasuraClauses({
20051
- page,
20052
- pageSize,
20053
- searchTerm,
20054
- filters,
20055
- order: cleanedOrder,
20056
- schema
20057
- });
20058
- initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
20059
- addCustomColumnFilters(where, schema.fields, currentParams);
20060
- if (isLocalCall) {
20061
- toRet = __spreadValues(__spreadValues({}, toRet), filterLocalEntitiesToHasura(entities, {
20062
- where,
20063
- order_by,
20064
- limit,
20065
- offset: offset3,
20066
- isInfinite
20067
- }));
20068
- return toRet;
20069
- } else {
20070
- return __spreadProps(__spreadValues({}, toRet), {
20071
- variables: {
20072
- where,
20073
- order_by,
20074
- limit,
20075
- offset: offset3
20076
- }
20118
+ const tableQueryParams = __spreadValues(__spreadValues({}, defaults), currentParams);
20119
+ let { page, pageSize, searchTerm, filters, order: order2 } = tableQueryParams;
20120
+ const ccFields = getFieldsMappedByCCDisplayName(schema);
20121
+ cleanupFilters({ filters, ccFields });
20122
+ if (page <= 0 || isNaN(page)) {
20123
+ page = void 0;
20124
+ }
20125
+ if (isInfinite) {
20126
+ page = void 0;
20127
+ pageSize = void 0;
20128
+ }
20129
+ if (pageSize !== void 0 && !doNotCoercePageSize) {
20130
+ const closest = clone$1(window.tgPageSizes || defaultPageSizes).sort(
20131
+ (a2, b2) => Math.abs(pageSize - a2) - Math.abs(pageSize - b2)
20132
+ )[0];
20133
+ pageSize = closest;
20134
+ }
20135
+ const cleanedOrder = [];
20136
+ if (order2 && order2.length) {
20137
+ order2.forEach((orderVal) => {
20138
+ const ccDisplayName = orderVal.replace(/^-/gi, "");
20139
+ const schemaForField = ccFields[ccDisplayName];
20140
+ if (schemaForField) {
20141
+ const { path: path2 } = schemaForField;
20142
+ const reversed = ccDisplayName !== orderVal;
20143
+ const prefix2 = reversed ? "-" : "";
20144
+ cleanedOrder.push(prefix2 + path2);
20145
+ } else {
20146
+ !noOrderError && console.error(
20147
+ "No schema for field found!",
20148
+ ccDisplayName,
20149
+ JSON.stringify(schema.fields, null, 2)
20150
+ );
20151
+ }
20152
+ });
20153
+ }
20154
+ let toRet = {
20155
+ //these are values that might be generally useful for the wrapped component
20156
+ page,
20157
+ pageSize: ownProps.controlled_pageSize || pageSize,
20158
+ order: cleanedOrder,
20159
+ filters,
20160
+ searchTerm
20161
+ };
20162
+ const { where, order_by, limit, offset: offset3 } = tableQueryParamsToHasuraClauses({
20163
+ page,
20164
+ pageSize,
20165
+ searchTerm,
20166
+ filters,
20167
+ order: cleanedOrder,
20168
+ schema
20077
20169
  });
20170
+ initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
20171
+ if (isLocalCall) {
20172
+ const newEnts = filterLocalEntitiesToHasura(
20173
+ prepEntitiesForLocalFilter({ entities, ccFields }),
20174
+ {
20175
+ where,
20176
+ order_by: (Array.isArray(order_by) ? order_by : [order_by]).map(
20177
+ (obj) => {
20178
+ const path2 = Object.keys(obj)[0];
20179
+ return __spreadValues({
20180
+ path: path2,
20181
+ direction: obj[path2],
20182
+ ownProps
20183
+ }, ccFields[path2]);
20184
+ }
20185
+ ),
20186
+ limit,
20187
+ offset: offset3,
20188
+ isInfinite
20189
+ }
20190
+ );
20191
+ toRet = __spreadValues(__spreadValues({}, toRet), newEnts);
20192
+ return toRet;
20193
+ } else {
20194
+ if (!order_by.length) {
20195
+ order_by.push({ updatedAt: "desc" });
20196
+ }
20197
+ order_by.push(
20198
+ isCodeModel ? { code: "desc" } : { [window.__sortId || "id"]: "desc" }
20199
+ );
20200
+ return __spreadProps(__spreadValues({}, toRet), {
20201
+ variables: {
20202
+ where,
20203
+ order_by,
20204
+ limit,
20205
+ offset: offset3
20206
+ }
20207
+ });
20208
+ }
20209
+ } catch (e) {
20210
+ if (urlConnected) {
20211
+ errorParsingUrlString = e;
20212
+ console.error(
20213
+ "The following error occurred when trying to build the query params. This is probably due to a malformed URL:",
20214
+ e
20215
+ );
20216
+ return {
20217
+ errorParsingUrlString,
20218
+ variables: {
20219
+ where: {},
20220
+ order_by: [],
20221
+ limit: 0,
20222
+ offset: 0
20223
+ }
20224
+ };
20225
+ } else {
20226
+ console.error("Error building query params from filter:");
20227
+ throw e;
20228
+ }
20078
20229
  }
20079
20230
  }
20080
20231
  __name(getQueryParams, "getQueryParams");
20232
+ function prepEntitiesForLocalFilter({ entities, ccFields }) {
20233
+ const r2 = entities.map((entity) => {
20234
+ const newEnt = __spreadValues({}, entity);
20235
+ forEach(ccFields, ({ getValueToFilterOn, path: path2 }) => {
20236
+ if (getValueToFilterOn) {
20237
+ newEnt["___original___" + path2] = newEnt[path2];
20238
+ const value = getValueToFilterOn(newEnt);
20239
+ newEnt[path2] = value;
20240
+ }
20241
+ });
20242
+ return newEnt;
20243
+ });
20244
+ return r2;
20245
+ }
20246
+ __name(prepEntitiesForLocalFilter, "prepEntitiesForLocalFilter");
20081
20247
  function PagingInput({ disabled, onBlur, defaultPage }) {
20082
20248
  const [page, setPage] = React.useState(defaultPage);
20083
20249
  const defaultValue2 = React.useRef(defaultPage);
@@ -31881,7 +32047,15 @@ function requireColor() {
31881
32047
  __name(requireColor, "requireColor");
31882
32048
  var colorExports = requireColor();
31883
32049
  const Color = /* @__PURE__ */ getDefaultExportFromCjs(colorExports);
31884
- const determineBlackOrWhiteTextColor = /* @__PURE__ */ __name((c2) => Color(c2).isLight() ? "#000000" : "#FFFFFF", "determineBlackOrWhiteTextColor");
32050
+ function determineBlackOrWhiteTextColor(c2) {
32051
+ try {
32052
+ return Color(c2).isLight() ? "#000000" : "#FFFFFF";
32053
+ } catch (e) {
32054
+ console.error("Error in color parsing:", e);
32055
+ return "#000000";
32056
+ }
32057
+ }
32058
+ __name(determineBlackOrWhiteTextColor, "determineBlackOrWhiteTextColor");
31885
32059
  function getTagsAndTagOptions(allTags) {
31886
32060
  return flatMap(allTags, (tag) => {
31887
32061
  if (tag.tagOptions && tag.tagOptions.length) {
@@ -51204,7 +51378,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
51204
51378
  if (order2 && order2.length) {
51205
51379
  order2.forEach((order22) => {
51206
51380
  const orderField = order22.replace("-", "");
51207
- if (orderField === ccDisplayName) {
51381
+ if (orderField === path2) {
51208
51382
  if (orderField === order22) {
51209
51383
  ordering = "asc";
51210
51384
  } else {
@@ -56295,6 +56469,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
56295
56469
  doNotCoercePageSize,
56296
56470
  currentParams,
56297
56471
  entities: props.entities,
56472
+ // for local table
56473
+ urlConnected,
56298
56474
  defaults,
56299
56475
  schema: convertedSchema,
56300
56476
  isInfinite,
@@ -58687,7 +58863,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58687
58863
  try {
58688
58864
  const allEntities = yield safeQuery(fragment, {
58689
58865
  variables: {
58690
- filter: variables.filter,
58866
+ where: variables.where,
58691
58867
  sort: variables.sort
58692
58868
  },
58693
58869
  canCancel: true
@@ -69067,6 +69243,7 @@ function parseCsvOrExcelFile(_0) {
69067
69243
  }
69068
69244
  __name(parseCsvOrExcelFile, "parseCsvOrExcelFile");
69069
69245
  const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(exports, null, function* () {
69246
+ var _a, _b, _c, _d;
69070
69247
  if (!file || Array.isArray(file) && !file.length) return [];
69071
69248
  const zipExtracted = yield extractZipFiles(file);
69072
69249
  const acceptedFiles = [];
@@ -69076,9 +69253,12 @@ const filterFilesInZip = /* @__PURE__ */ __name((file, accepted) => __async(expo
69076
69253
  }
69077
69254
  }
69078
69255
  if (acceptedFiles.length && acceptedFiles.length < zipExtracted.length)
69079
- window.toastr.warning("Some files don't have the proper file extension.");
69256
+ (_b = (_a = window == null ? void 0 : window.toastr) == null ? void 0 : _a.warning) == null ? void 0 : _b.call(
69257
+ _a,
69258
+ "Some files don't have the proper file extension."
69259
+ );
69080
69260
  if (!acceptedFiles.length)
69081
- window.toastr.warning("No files with the proper extension were found.");
69261
+ (_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
69262
  return acceptedFiles;
69083
69263
  }), "filterFilesInZip");
69084
69264
  function removeExt(filename) {
@@ -71806,12 +71986,15 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
71806
71986
  doNotCoercePageSize,
71807
71987
  currentParams,
71808
71988
  entities,
71989
+ // for local table
71990
+ urlConnected,
71809
71991
  defaults: defaultsToUse,
71810
71992
  schema: convertedSchema,
71811
71993
  isInfinite: isInfinite || isSimple && !withPaging,
71812
71994
  isLocalCall,
71813
71995
  additionalFilter,
71814
71996
  noOrderError,
71997
+ isCodeModel,
71815
71998
  ownProps: passingProps
71816
71999
  });
71817
72000
  }, [
@@ -77970,6 +78153,7 @@ exports.createDynamicBarMenu = createDynamicBarMenu;
77970
78153
  exports.createDynamicMenu = createDynamicMenu;
77971
78154
  exports.createMenu = createMenu;
77972
78155
  exports.designIcon = designIcon;
78156
+ exports.determineBlackOrWhiteTextColor = determineBlackOrWhiteTextColor;
77973
78157
  exports.dnaIcon = dnaIcon;
77974
78158
  exports.doesSearchValMatchText = doesSearchValMatchText;
77975
78159
  exports.driveIcon = driveIcon;