autoql-fe-utils 1.10.21 → 1.10.22

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.
@@ -17014,6 +17014,139 @@
17014
17014
  return array3.slice(0, index).concat(array3.slice(index + 1));
17015
17015
  };
17016
17016
 
17017
+ // src/HelperFns/filterEngine.ts
17018
+ var FilterOperatorEnum = /* @__PURE__ */ ((FilterOperatorEnum2) => {
17019
+ FilterOperatorEnum2["LIKE"] = "like";
17020
+ FilterOperatorEnum2["NOT_LIKE"] = "not_like";
17021
+ FilterOperatorEnum2["EQ"] = "=";
17022
+ FilterOperatorEnum2["NEQ"] = "!=";
17023
+ FilterOperatorEnum2["LT"] = "<";
17024
+ FilterOperatorEnum2["GT"] = ">";
17025
+ FilterOperatorEnum2["LTE"] = "<=";
17026
+ FilterOperatorEnum2["GTE"] = ">=";
17027
+ FilterOperatorEnum2["REGEX"] = "regex";
17028
+ FilterOperatorEnum2["STARTS_WITH"] = "starts_with";
17029
+ FilterOperatorEnum2["ENDS_WITH"] = "ends_with";
17030
+ return FilterOperatorEnum2;
17031
+ })(FilterOperatorEnum || {});
17032
+ var likeMatcher = (cell, cond) => {
17033
+ var _a;
17034
+ if (cell == null) return false;
17035
+ const needle = String((_a = cond.value) != null ? _a : "").toLowerCase();
17036
+ if (needle.length === 0) return false;
17037
+ return String(cell).toLowerCase().includes(needle);
17038
+ };
17039
+ var notLikeMatcher = (cell, cond) => {
17040
+ var _a;
17041
+ if (cell == null) return false;
17042
+ const needle = String((_a = cond.value) != null ? _a : "").toLowerCase();
17043
+ if (needle.length === 0) return true;
17044
+ return !String(cell).toLowerCase().includes(needle);
17045
+ };
17046
+ var equalMatcher = (cell, cond) => {
17047
+ if (cond.type === "number") return Number(cell) === Number(cond.value);
17048
+ return String(cell) === String(cond.value);
17049
+ };
17050
+ var notEqualMatcher = (cell, cond) => {
17051
+ return !equalMatcher(cell, cond);
17052
+ };
17053
+ var lessThanMatcher = (cell, cond) => Number(cell) < Number(cond.value);
17054
+ var lessThanEqMatcher = (cell, cond) => Number(cell) <= Number(cond.value);
17055
+ var greaterThanMatcher = (cell, cond) => Number(cell) > Number(cond.value);
17056
+ var greaterThanEqMatcher = (cell, cond) => Number(cell) >= Number(cond.value);
17057
+ var regexMatcher = (cell, cond) => {
17058
+ const reg = new RegExp(String(cond.value));
17059
+ return reg.test(String(cell));
17060
+ };
17061
+ var FILTER_MATCHERS = {
17062
+ like: likeMatcher,
17063
+ not_like: notLikeMatcher,
17064
+ "=": equalMatcher,
17065
+ "!=": notEqualMatcher,
17066
+ "<": lessThanMatcher,
17067
+ "<=": lessThanEqMatcher,
17068
+ ">": greaterThanMatcher,
17069
+ ">=": greaterThanEqMatcher,
17070
+ regex: regexMatcher,
17071
+ starts_with: (cell, cond) => String(cell).startsWith(String(cond.value)),
17072
+ ends_with: (cell, cond) => String(cell).endsWith(String(cond.value))
17073
+ };
17074
+ function isValidOperator(op) {
17075
+ return Object.values(FilterOperatorEnum).includes(op);
17076
+ }
17077
+ var FILTER_TYPES = ["string", "number", "date", "boolean"];
17078
+ function isValidFilterType(t) {
17079
+ return FILTER_TYPES.includes(t);
17080
+ }
17081
+ function escapeRegExp(str) {
17082
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17083
+ }
17084
+ function parseLocaleNumber(value, locale3) {
17085
+ var _a, _b;
17086
+ if (typeof value === "number") return value;
17087
+ let str = String(value != null ? value : "").trim();
17088
+ if (str.length === 0) return NaN;
17089
+ str = str.replace(/\s|\u00A0/g, "");
17090
+ try {
17091
+ const parts = Intl.NumberFormat(locale3).formatToParts(12345.6);
17092
+ const group = (_a = parts.find((p) => p.type === "group")) == null ? void 0 : _a.value;
17093
+ const decimal = (_b = parts.find((p) => p.type === "decimal")) == null ? void 0 : _b.value;
17094
+ if (group) {
17095
+ str = str.replace(new RegExp(escapeRegExp(group), "g"), "");
17096
+ }
17097
+ if (decimal && decimal !== ".") {
17098
+ str = str.replace(new RegExp(escapeRegExp(decimal), "g"), ".");
17099
+ }
17100
+ } catch (e) {
17101
+ str = str.replace(/[,']/g, "");
17102
+ }
17103
+ const n = Number(str);
17104
+ return Number.isFinite(n) ? n : NaN;
17105
+ }
17106
+ var _logger = console;
17107
+ function setLogger(logger) {
17108
+ _logger = { ..._logger, ...logger };
17109
+ }
17110
+ function getLogger() {
17111
+ return _logger;
17112
+ }
17113
+ function parseFilter(raw, type, defaultOperator = "like") {
17114
+ var _a, _b;
17115
+ if (typeof raw !== "string") return { operator: defaultOperator, value: raw, type };
17116
+ const trimmed = raw.trim();
17117
+ if (trimmed.length === 0) return { operator: defaultOperator, value: "", type };
17118
+ const opMatch = /^([<>!=]=?|not_like)\s*(.*)$/i.exec(trimmed);
17119
+ if (opMatch) {
17120
+ let op = String((_a = opMatch[1]) != null ? _a : "").toLowerCase();
17121
+ const rest = (_b = opMatch[2]) != null ? _b : "";
17122
+ if (op === "!") op = "not_like";
17123
+ if (type === "string" && op === "!=") op = "not_like";
17124
+ if (type === "number") {
17125
+ const n = parseLocaleNumber(rest);
17126
+ if (!isValidOperator(op)) {
17127
+ getLogger().warn("parseFilter: unknown operator", op, "falling back to defaultOperator");
17128
+ return { operator: defaultOperator, value: n, type };
17129
+ }
17130
+ return { operator: op, value: n, type };
17131
+ }
17132
+ if (!isValidOperator(op)) {
17133
+ getLogger().warn("parseFilter: unknown operator", op, "falling back to defaultOperator");
17134
+ return { operator: defaultOperator, value: rest, type };
17135
+ }
17136
+ return { operator: op, value: rest, type };
17137
+ }
17138
+ if (type === "number") {
17139
+ const n = parseLocaleNumber(trimmed);
17140
+ return { operator: defaultOperator, value: n, type };
17141
+ }
17142
+ return { operator: defaultOperator, value: trimmed, type };
17143
+ }
17144
+ function matchCell(cellValue, condition) {
17145
+ const matcher = FILTER_MATCHERS[condition.operator];
17146
+ if (!matcher) throw new Error(`Unknown filter operator: ${condition.operator}`);
17147
+ return matcher(cellValue, condition);
17148
+ }
17149
+
17017
17150
  // src/HelperFns/tableHelpers.ts
17018
17151
  var normalizeOperator = (op) => op === "!" ? "not_like" : op;
17019
17152
  function getColumnIdentifierCompat(col) {
@@ -17153,7 +17286,7 @@
17153
17286
  const isBareNumeric = typeof rawValue === "number";
17154
17287
  const isBareString = typeof rawValue === "string" && rawStr !== "" && !rawStr.startsWith("=");
17155
17288
  if (opStr === "=" && (isBareNumeric || isBareString && rawStr !== "")) {
17156
- operator = "like";
17289
+ operator = "like" /* LIKE */;
17157
17290
  } else {
17158
17291
  operator = filter3.operator;
17159
17292
  }
@@ -17168,14 +17301,12 @@
17168
17301
  operator,
17169
17302
  id: column.id
17170
17303
  };
17171
- if (isColumnNumberType(column)) {
17172
- if (!operatorExtracted) {
17173
- const formatted = formatNumberFilterValue(stringValue);
17174
- if (formatted.value !== "") {
17175
- filterObj.value = formatted.value;
17176
- if ((filter3 == null ? void 0 : filter3.operator) === void 0) {
17177
- filterObj.operator = formatted.operator;
17178
- }
17304
+ if (isColumnNumberType(column) && !operatorExtracted) {
17305
+ const formatted = formatNumberFilterValue(stringValue);
17306
+ if (formatted.value !== "") {
17307
+ filterObj.value = formatted.value;
17308
+ if ((filter3 == null ? void 0 : filter3.operator) === void 0) {
17309
+ filterObj.operator = formatted.operator;
17179
17310
  }
17180
17311
  }
17181
17312
  }
@@ -17224,7 +17355,7 @@
17224
17355
  formattedValue = `${dayjsWithPlugins_default(start).format("YYYY-MM-DD")} to ${dayjsWithPlugins_default(end).format("YYYY-MM-DD")}`;
17225
17356
  } else if (filter3.operator === "not_like") {
17226
17357
  formattedValue = `!${filter3.value}`;
17227
- } else if (filter3.operator === "like") {
17358
+ } else if (filter3.operator === "like" /* LIKE */) {
17228
17359
  formattedValue = `${filter3.value}`;
17229
17360
  } else if (filter3.operator === "!" || filter3.operator === "!=") {
17230
17361
  formattedValue = `${filter3.operator}${filter3.value}`;
@@ -17283,139 +17414,6 @@
17283
17414
  }
17284
17415
  };
17285
17416
 
17286
- // src/HelperFns/filterEngine.ts
17287
- var FilterOperatorEnum = /* @__PURE__ */ ((FilterOperatorEnum2) => {
17288
- FilterOperatorEnum2["LIKE"] = "like";
17289
- FilterOperatorEnum2["NOT_LIKE"] = "not_like";
17290
- FilterOperatorEnum2["EQ"] = "=";
17291
- FilterOperatorEnum2["NEQ"] = "!=";
17292
- FilterOperatorEnum2["LT"] = "<";
17293
- FilterOperatorEnum2["GT"] = ">";
17294
- FilterOperatorEnum2["LTE"] = "<=";
17295
- FilterOperatorEnum2["GTE"] = ">=";
17296
- FilterOperatorEnum2["REGEX"] = "regex";
17297
- FilterOperatorEnum2["STARTS_WITH"] = "starts_with";
17298
- FilterOperatorEnum2["ENDS_WITH"] = "ends_with";
17299
- return FilterOperatorEnum2;
17300
- })(FilterOperatorEnum || {});
17301
- var likeMatcher = (cell, cond) => {
17302
- var _a;
17303
- if (cell == null) return false;
17304
- const needle = String((_a = cond.value) != null ? _a : "").toLowerCase();
17305
- if (needle.length === 0) return false;
17306
- return String(cell).toLowerCase().includes(needle);
17307
- };
17308
- var notLikeMatcher = (cell, cond) => {
17309
- var _a;
17310
- if (cell == null) return false;
17311
- const needle = String((_a = cond.value) != null ? _a : "").toLowerCase();
17312
- if (needle.length === 0) return true;
17313
- return !String(cell).toLowerCase().includes(needle);
17314
- };
17315
- var equalMatcher = (cell, cond) => {
17316
- if (cond.type === "number") return Number(cell) === Number(cond.value);
17317
- return String(cell) === String(cond.value);
17318
- };
17319
- var notEqualMatcher = (cell, cond) => {
17320
- return !equalMatcher(cell, cond);
17321
- };
17322
- var lessThanMatcher = (cell, cond) => Number(cell) < Number(cond.value);
17323
- var lessThanEqMatcher = (cell, cond) => Number(cell) <= Number(cond.value);
17324
- var greaterThanMatcher = (cell, cond) => Number(cell) > Number(cond.value);
17325
- var greaterThanEqMatcher = (cell, cond) => Number(cell) >= Number(cond.value);
17326
- var regexMatcher = (cell, cond) => {
17327
- const reg = new RegExp(String(cond.value));
17328
- return reg.test(String(cell));
17329
- };
17330
- var FILTER_MATCHERS = {
17331
- like: likeMatcher,
17332
- not_like: notLikeMatcher,
17333
- "=": equalMatcher,
17334
- "!=": notEqualMatcher,
17335
- "<": lessThanMatcher,
17336
- "<=": lessThanEqMatcher,
17337
- ">": greaterThanMatcher,
17338
- ">=": greaterThanEqMatcher,
17339
- regex: regexMatcher,
17340
- starts_with: (cell, cond) => String(cell).startsWith(String(cond.value)),
17341
- ends_with: (cell, cond) => String(cell).endsWith(String(cond.value))
17342
- };
17343
- function isValidOperator(op) {
17344
- return Object.values(FilterOperatorEnum).includes(op);
17345
- }
17346
- var FILTER_TYPES = ["string", "number", "date", "boolean"];
17347
- function isValidFilterType(t) {
17348
- return FILTER_TYPES.includes(t);
17349
- }
17350
- function escapeRegExp(str) {
17351
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17352
- }
17353
- function parseLocaleNumber(value, locale3) {
17354
- var _a, _b;
17355
- if (typeof value === "number") return value;
17356
- let str = String(value != null ? value : "").trim();
17357
- if (str.length === 0) return NaN;
17358
- str = str.replace(/\s|\u00A0/g, "");
17359
- try {
17360
- const parts = Intl.NumberFormat(locale3).formatToParts(12345.6);
17361
- const group = (_a = parts.find((p) => p.type === "group")) == null ? void 0 : _a.value;
17362
- const decimal = (_b = parts.find((p) => p.type === "decimal")) == null ? void 0 : _b.value;
17363
- if (group) {
17364
- str = str.replace(new RegExp(escapeRegExp(group), "g"), "");
17365
- }
17366
- if (decimal && decimal !== ".") {
17367
- str = str.replace(new RegExp(escapeRegExp(decimal), "g"), ".");
17368
- }
17369
- } catch (e) {
17370
- str = str.replace(/[,']/g, "");
17371
- }
17372
- const n = Number(str);
17373
- return Number.isFinite(n) ? n : NaN;
17374
- }
17375
- var _logger = console;
17376
- function setLogger(logger) {
17377
- _logger = { ..._logger, ...logger };
17378
- }
17379
- function getLogger() {
17380
- return _logger;
17381
- }
17382
- function parseFilter(raw, type, defaultOperator = "like") {
17383
- var _a, _b;
17384
- if (typeof raw !== "string") return { operator: defaultOperator, value: raw, type };
17385
- const trimmed = raw.trim();
17386
- if (trimmed.length === 0) return { operator: defaultOperator, value: "", type };
17387
- const opMatch = /^([<>!=]=?|not_like)\s*(.*)$/i.exec(trimmed);
17388
- if (opMatch) {
17389
- let op = String((_a = opMatch[1]) != null ? _a : "").toLowerCase();
17390
- const rest = (_b = opMatch[2]) != null ? _b : "";
17391
- if (op === "!") op = "not_like";
17392
- if (type === "string" && op === "!=") op = "not_like";
17393
- if (type === "number") {
17394
- const n = parseLocaleNumber(rest);
17395
- if (!isValidOperator(op)) {
17396
- getLogger().warn("parseFilter: unknown operator", op, "falling back to defaultOperator");
17397
- return { operator: defaultOperator, value: n, type };
17398
- }
17399
- return { operator: op, value: n, type };
17400
- }
17401
- if (!isValidOperator(op)) {
17402
- getLogger().warn("parseFilter: unknown operator", op, "falling back to defaultOperator");
17403
- return { operator: defaultOperator, value: rest, type };
17404
- }
17405
- return { operator: op, value: rest, type };
17406
- }
17407
- if (type === "number") {
17408
- const n = parseLocaleNumber(trimmed);
17409
- return { operator: defaultOperator, value: n, type };
17410
- }
17411
- return { operator: defaultOperator, value: trimmed, type };
17412
- }
17413
- function matchCell(cellValue, condition) {
17414
- const matcher = FILTER_MATCHERS[condition.operator];
17415
- if (!matcher) throw new Error(`Unknown filter operator: ${condition.operator}`);
17416
- return matcher(cellValue, condition);
17417
- }
17418
-
17419
17417
  // src/HelperFns/columnHelpers.ts
17420
17418
  var isColumnSummable = (col) => {
17421
17419
  const type = col == null ? void 0 : col.type;
@@ -17614,7 +17612,7 @@
17614
17612
  };
17615
17613
  var matchesStringFilter = (raw, haystack) => {
17616
17614
  if (!raw.length) return false;
17617
- const { operator = "like", cleanValue = raw.trim() } = extractOperatorFromValue(raw, "like") || {};
17615
+ const { operator = "like" /* LIKE */, cleanValue = raw.trim() } = extractOperatorFromValue(raw, "like" /* LIKE */) || {};
17618
17616
  const needle = cleanValue.toLowerCase();
17619
17617
  if (operator === "!" || operator === "!=") return !needle.length || !haystack.includes(needle);
17620
17618
  return !!needle.length && haystack.includes(needle);
@@ -17699,7 +17697,7 @@
17699
17697
  }
17700
17698
  const raw = String(headerValue != null ? headerValue : "").trim();
17701
17699
  const lowerValue = String(rowValue != null ? rowValue : "").toLowerCase();
17702
- const cond = parseFilter(raw, "string", "like");
17700
+ const cond = parseFilter(raw, "string", "like" /* LIKE */);
17703
17701
  return matchCell(lowerValue, { ...cond, type: "string", value: String(cond.value).toLowerCase() });
17704
17702
  };
17705
17703
  }
@@ -18837,7 +18835,7 @@
18837
18835
  if ((filterValue === "0" || filterValue === 0) && (colType === "QUANTITY" /* QUANTITY */ || colType === "DOLLAR_AMT" /* DOLLAR_AMT */)) {
18838
18836
  filterValue = Number(filterValue);
18839
18837
  }
18840
- const op = (operator != null ? operator : "like").toString().toLowerCase();
18838
+ const op = (operator != null ? operator : "like" /* LIKE */).toString().toLowerCase();
18841
18839
  const isNil = (v) => v === void 0 || v === null;
18842
18840
  const toStr = (v) => String(v != null ? v : "");
18843
18841
  const ci = (v) => toStr(v).toLowerCase();
@@ -18848,7 +18846,7 @@
18848
18846
  if (!/,/.test(s) && !/\s+to\s+/.test(s)) return [s];
18849
18847
  return s.split(/\s*,\s*|\s+to\s+/);
18850
18848
  };
18851
- if (op === "like" || op === "includes" || op === "contains") {
18849
+ if (op === "like" /* LIKE */ || op === "includes" || op === "contains") {
18852
18850
  if (colType === "DATE" /* DATE */) {
18853
18851
  return data.concat().filter((row) => {
18854
18852
  var _a;
@@ -24811,7 +24809,7 @@
24811
24809
  const isoDateEnd = isoDate.endOf(precision).toISOString();
24812
24810
  formattedValue = `${isoDateStart},${isoDateEnd}`;
24813
24811
  operator = "between";
24814
- columnType = "TIME";
24812
+ columnType = "DATE" /* DATE */;
24815
24813
  } else if (isColumnNumberType(column)) {
24816
24814
  formattedValue = `${value}`;
24817
24815
  operator = "=";