@universe-platform/ui 0.1.0-beta.66 → 0.1.0-beta.67

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/dist/index.mjs CHANGED
@@ -713,6 +713,187 @@ function formatFileSize(bytes) {
713
713
  return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
714
714
  }
715
715
 
716
+ // ../shared/src/formulaFilters.ts
717
+ var MAX_FILTER_CONDITIONS = 5;
718
+ var MAX_VALUE_LENGTH = 200;
719
+ function filterKindOfType(type) {
720
+ const t = String(type || "").toUpperCase();
721
+ if (t === "NUMBER" || t === "CURRENCY") return "number";
722
+ if (t === "DATE") return "date";
723
+ if (t === "BOOLEAN") return "boolean";
724
+ if (t === "RELATION") return "relation";
725
+ return "text";
726
+ }
727
+ var op = (id, label, needsValue = true) => ({ id, label, needsValue });
728
+ var EMPTY_OPS = [op("empty", "\u05E8\u05D9\u05E7", false), op("notempty", "\u05DC\u05D0 \u05E8\u05D9\u05E7", false)];
729
+ var OPS_BY_KIND = {
730
+ text: [
731
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
732
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
733
+ op("contains", "\u05DE\u05DB\u05D9\u05DC"),
734
+ op("notcontains", "\u05DC\u05D0 \u05DE\u05DB\u05D9\u05DC"),
735
+ op("starts", "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1"),
736
+ op("ends", "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1"),
737
+ op("in", "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA (\u05DE\u05D5\u05E4\u05E8\u05D3\u05D9\u05DD \u05D1\u05E4\u05E1\u05D9\u05E7)"),
738
+ ...EMPTY_OPS
739
+ ],
740
+ relation: [
741
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
742
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
743
+ op("contains", "\u05DE\u05DB\u05D9\u05DC"),
744
+ op("in", "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA (\u05DE\u05D5\u05E4\u05E8\u05D3\u05D9\u05DD \u05D1\u05E4\u05E1\u05D9\u05E7)"),
745
+ ...EMPTY_OPS
746
+ ],
747
+ number: [
748
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
749
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
750
+ op("gt", "\u05D2\u05D3\u05D5\u05DC \u05DE"),
751
+ op("lt", "\u05E7\u05D8\u05DF \u05DE"),
752
+ op("ge", "\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC"),
753
+ op("le", "\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC"),
754
+ ...EMPTY_OPS
755
+ ],
756
+ date: [
757
+ op("eq", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA"),
758
+ op("ne", "\u05DC\u05D0 \u05D1\u05EA\u05D0\u05E8\u05D9\u05DA"),
759
+ op("gt", "\u05D0\u05D7\u05E8\u05D9"),
760
+ op("lt", "\u05DC\u05E4\u05E0\u05D9"),
761
+ op("ge", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05D0\u05D7\u05E8\u05D9\u05D5"),
762
+ op("le", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05DC\u05E4\u05E0\u05D9\u05D5"),
763
+ ...EMPTY_OPS
764
+ ],
765
+ boolean: [op("yes", "\u05DE\u05E1\u05D5\u05DE\u05DF (\u05DB\u05DF)", false), op("no", "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF (\u05DC\u05D0)", false)]
766
+ };
767
+ var getFilterOps = (type) => OPS_BY_KIND[filterKindOfType(type)];
768
+ var ALL_OPS = new Set(Object.values(OPS_BY_KIND).flat().map((o) => o.id));
769
+ var NEEDS_VALUE = new Map(Object.values(OPS_BY_KIND).flat().map((o) => [o.id, o.needsValue]));
770
+ function sanitizeRefFilter(raw) {
771
+ if (!raw || typeof raw !== "object") return null;
772
+ const r = raw;
773
+ if (!Array.isArray(r.conditions)) return null;
774
+ const conditions = [];
775
+ for (const c of r.conditions.slice(0, MAX_FILTER_CONDITIONS)) {
776
+ if (!c || typeof c !== "object") continue;
777
+ const field = typeof c.field === "string" ? c.field.trim().slice(0, MAX_VALUE_LENGTH) : "";
778
+ const opId = typeof c.op === "string" ? c.op : "";
779
+ if (!field || !ALL_OPS.has(opId)) continue;
780
+ const needs = NEEDS_VALUE.get(opId) === true;
781
+ const value = typeof c.value === "string" ? c.value.trim().slice(0, MAX_VALUE_LENGTH) : typeof c.value === "number" ? String(c.value) : "";
782
+ if (needs && value === "") continue;
783
+ conditions.push({ field, op: opId, value: needs ? value : "" });
784
+ }
785
+ if (conditions.length === 0) return null;
786
+ return { join: r.join === "OR" ? "OR" : "AND", conditions };
787
+ }
788
+ function filterSignature(f) {
789
+ var _a;
790
+ if (!f || !((_a = f.conditions) == null ? void 0 : _a.length)) return "";
791
+ return `${f.join}:${f.conditions.map((c) => `${c.field}${c.op}${c.value}`).join("")}`;
792
+ }
793
+ var SHORT_LABELS = {
794
+ eq: "=",
795
+ ne: "\u2260",
796
+ gt: ">",
797
+ lt: "<",
798
+ ge: "\u2265",
799
+ le: "\u2264",
800
+ contains: "\u05DE\u05DB\u05D9\u05DC",
801
+ notcontains: "\u05DC\u05D0 \u05DE\u05DB\u05D9\u05DC",
802
+ starts: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1",
803
+ ends: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1",
804
+ in: "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA",
805
+ empty: "\u05E8\u05D9\u05E7",
806
+ notempty: "\u05DC\u05D0 \u05E8\u05D9\u05E7",
807
+ yes: "\u05DE\u05E1\u05D5\u05DE\u05DF",
808
+ no: "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF"
809
+ };
810
+ function describeRefFilter(f) {
811
+ var _a;
812
+ if (!f || !((_a = f.conditions) == null ? void 0 : _a.length)) return "";
813
+ const sep = f.join === "OR" ? " \u05D0\u05D5 " : " \u05D5\u05D2\u05DD ";
814
+ return f.conditions.map((c) => {
815
+ const needs = NEEDS_VALUE.get(c.op) === true;
816
+ return needs ? `${c.field} ${SHORT_LABELS[c.op]} ${c.value}` : `${c.field} ${SHORT_LABELS[c.op]}`;
817
+ }).join(sep);
818
+ }
819
+ var norm = (x) => String(x != null ? x : "").trim().toLowerCase();
820
+ var isBlankValue = (x) => x === null || x === void 0 || typeof x === "string" && x.trim() === "" || Array.isArray(x) && x.every(isBlankValue);
821
+ var isoDate = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x.trim()) ? x.trim().slice(0, 10) : null;
822
+ var numOf = (x) => {
823
+ if (typeof x === "number") return Number.isFinite(x) ? x : null;
824
+ if (typeof x === "string" && x.trim() !== "") {
825
+ const n = Number(x);
826
+ return Number.isFinite(n) ? n : null;
827
+ }
828
+ return null;
829
+ };
830
+ function compare(l, r) {
831
+ const ld = isoDate(l), rd = isoDate(r);
832
+ if (ld && rd) return ld < rd ? -1 : ld > rd ? 1 : 0;
833
+ const ln = numOf(l), rn = numOf(r);
834
+ if (ln !== null && rn !== null) return ln < rn ? -1 : ln > rn ? 1 : 0;
835
+ const a = norm(l), b = norm(r);
836
+ return a < b ? -1 : a > b ? 1 : 0;
837
+ }
838
+ var NEGATED = { ne: "eq", notcontains: "contains" };
839
+ function matchSingle(opId, v, target) {
840
+ switch (opId) {
841
+ case "eq":
842
+ return !isBlankValue(v) && compare(v, target) === 0;
843
+ case "ne":
844
+ return isBlankValue(v) || compare(v, target) !== 0;
845
+ case "contains":
846
+ return norm(v).includes(norm(target));
847
+ case "notcontains":
848
+ return !norm(v).includes(norm(target));
849
+ case "starts":
850
+ return norm(v).startsWith(norm(target));
851
+ case "ends":
852
+ return norm(v).endsWith(norm(target));
853
+ case "in": {
854
+ const list = target.split(",").map(norm).filter(Boolean);
855
+ return list.includes(norm(v));
856
+ }
857
+ case "gt":
858
+ return !isBlankValue(v) && compare(v, target) > 0;
859
+ case "lt":
860
+ return !isBlankValue(v) && compare(v, target) < 0;
861
+ case "ge":
862
+ return !isBlankValue(v) && compare(v, target) >= 0;
863
+ case "le":
864
+ return !isBlankValue(v) && compare(v, target) <= 0;
865
+ case "empty":
866
+ return isBlankValue(v);
867
+ case "notempty":
868
+ return !isBlankValue(v);
869
+ case "yes": {
870
+ if (v === true) return true;
871
+ if (typeof v === "number") return v !== 0;
872
+ return ["true", "1", "yes", "\u05DB\u05DF"].includes(norm(v));
873
+ }
874
+ case "no":
875
+ return !matchSingle("yes", v, target);
876
+ default:
877
+ return false;
878
+ }
879
+ }
880
+ function matchCondition(c, raw) {
881
+ if (c.op === "empty") return isBlankValue(raw);
882
+ if (c.op === "notempty") return !isBlankValue(raw);
883
+ if (Array.isArray(raw)) {
884
+ const positive = NEGATED[c.op];
885
+ if (positive) return !raw.some((item) => matchSingle(positive, item, c.value));
886
+ return raw.some((item) => matchSingle(c.op, item, c.value));
887
+ }
888
+ return matchSingle(c.op, raw, c.value);
889
+ }
890
+ function matchesRefFilter(filter, getValue) {
891
+ var _a;
892
+ if (!filter || !((_a = filter.conditions) == null ? void 0 : _a.length)) return true;
893
+ const test = (c) => matchCondition(c, getValue(c.field));
894
+ return filter.join === "OR" ? filter.conditions.some(test) : filter.conditions.every(test);
895
+ }
896
+
716
897
  // ../shared/src/formula.ts
717
898
  var FORMULA_COLUMN_TYPE = "FORMULA";
718
899
  var FORMULA_SOURCE_TYPES = ["NUMBER", "CURRENCY", "STRING", "BOOLEAN", "DATE", "TIME", "PHONE"];
@@ -739,7 +920,10 @@ function makeCellRefKey(existing, field, agg) {
739
920
  for (let n = 2; (existing || []).some((r) => r.key === key); n++) key = `${base} (${n})`;
740
921
  return key;
741
922
  }
742
- var perRecordRefValueKey = (r) => `ref:${r.tableId}::${r.agg ? "" : r.recordId || ""}::${r.field}::${r.agg || ""}`;
923
+ var perRecordRefValueKey = (r) => {
924
+ const sig = r.agg ? filterSignature(r.filter) : "";
925
+ return `ref:${r.tableId}::${r.agg ? "" : r.recordId || ""}::${r.field}::${r.agg || ""}${sig ? `::${sig}` : ""}`;
926
+ };
743
927
  function sanitizeRefs(raw) {
744
928
  var _a, _b, _c, _d;
745
929
  if (!Array.isArray(raw)) return [];
@@ -752,15 +936,16 @@ function sanitizeRefs(raw) {
752
936
  const field = typeof r.field === "string" ? r.field : "";
753
937
  if (!key.startsWith("@") || seen.has(key) || !tableId || !field) continue;
754
938
  const agg = PER_RECORD_SOURCE_AGGS.includes(r.agg) ? r.agg : void 0;
939
+ const filter = agg ? sanitizeRefFilter(r.filter) : null;
755
940
  seen.add(key);
756
- out.push(__spreadValues({
941
+ out.push(__spreadValues(__spreadValues({
757
942
  key,
758
943
  tableId,
759
944
  tableName: String((_b = r.tableName) != null ? _b : "").slice(0, 200),
760
945
  recordId: agg ? "" : String((_c = r.recordId) != null ? _c : ""),
761
946
  recordLabel: agg ? "" : String((_d = r.recordLabel) != null ? _d : "").slice(0, 200),
762
947
  field
763
- }, agg ? { agg } : {}));
948
+ }, agg ? { agg } : {}), filter ? { filter } : {}));
764
949
  }
765
950
  return out;
766
951
  }
@@ -787,7 +972,8 @@ function describePerRecordFormula(f) {
787
972
  if (!f) return "";
788
973
  let text2 = f.expression;
789
974
  for (const r of f.refs) {
790
- const path = r.agg ? `${PER_RECORD_AGG_LABELS[r.agg]} ${r.tableName} \u203A ${r.field}` : `${r.tableName} \u203A ${r.recordLabel || "\u05E8\u05E9\u05D5\u05DE\u05D4"} \u203A ${r.field}`;
975
+ const filterText = r.agg ? describeRefFilter(r.filter) : "";
976
+ const path = r.agg ? `${PER_RECORD_AGG_LABELS[r.agg]} ${r.tableName} \u203A ${r.field}${filterText ? ` [${filterText}]` : ""}` : `${r.tableName} \u203A ${r.recordLabel || "\u05E8\u05E9\u05D5\u05DE\u05D4"} \u203A ${r.field}`;
791
977
  text2 = text2.split(`{${r.key}}`).join(`[${path}]`);
792
978
  }
793
979
  return text2;
@@ -837,10 +1023,10 @@ function tokenize(src) {
837
1023
  i += id[0].length;
838
1024
  continue;
839
1025
  }
840
- const op = /^(>=|<=|<>|[-+*/%(),<>=&])/.exec(rest);
841
- if (op) {
842
- toks.push({ k: "op", v: op[0] });
843
- i += op[0].length;
1026
+ const op2 = /^(>=|<=|<>|[-+*/%(),<>=&])/.exec(rest);
1027
+ if (op2) {
1028
+ toks.push({ k: "op", v: op2[0] });
1029
+ i += op2[0].length;
844
1030
  continue;
845
1031
  }
846
1032
  throw new Error(`\u05EA\u05D5 \u05DC\u05D0 \u05DE\u05D5\u05DB\u05E8 \u05D1\u05E0\u05D5\u05E1\u05D7\u05D4: ${c}`);
@@ -854,7 +1040,7 @@ var toNum = (x) => {
854
1040
  };
855
1041
  var isBlank = (x) => x === null || x === void 0 || x === "";
856
1042
  var isNumLike = (x) => typeof x === "number" || typeof x === "string" && x.trim() !== "" && Number.isFinite(Number(x));
857
- var isoDate = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x) ? x.slice(0, 10) : null;
1043
+ var isoDate2 = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x) ? x.slice(0, 10) : null;
858
1044
  var truthy = (x) => {
859
1045
  if (x === null || x === "") return false;
860
1046
  if (typeof x === "number") return x !== 0 && !Number.isNaN(x);
@@ -863,7 +1049,7 @@ var truthy = (x) => {
863
1049
  };
864
1050
  var text = (x) => String(x != null ? x : "").trim().toLowerCase();
865
1051
  function compareValues(l, r) {
866
- const ld = isoDate(l), rd = isoDate(r);
1052
+ const ld = isoDate2(l), rd = isoDate2(r);
867
1053
  if (ld && rd) return ld < rd ? -1 : ld > rd ? 1 : 0;
868
1054
  if ((isNumLike(l) || isBlank(l)) && (isNumLike(r) || isBlank(r))) {
869
1055
  const a2 = toNum(l), b2 = toNum(r);
@@ -904,9 +1090,9 @@ function evaluateFormula(expr, getField) {
904
1090
  function parseExpr() {
905
1091
  let l = parseConcat();
906
1092
  while (isOp(">", "<", ">=", "<=", "=", "<>")) {
907
- const op = eat().v, r = parseConcat();
1093
+ const op2 = eat().v, r = parseConcat();
908
1094
  const c = compareValues(l, r);
909
- l = (op === ">" ? c > 0 : op === "<" ? c < 0 : op === ">=" ? c >= 0 : op === "<=" ? c <= 0 : op === "=" ? c === 0 : c !== 0) ? 1 : 0;
1095
+ l = (op2 === ">" ? c > 0 : op2 === "<" ? c < 0 : op2 === ">=" ? c >= 0 : op2 === "<=" ? c <= 0 : op2 === "=" ? c === 0 : c !== 0) ? 1 : 0;
910
1096
  }
911
1097
  return l;
912
1098
  }
@@ -922,17 +1108,17 @@ function evaluateFormula(expr, getField) {
922
1108
  function parseAdd() {
923
1109
  let l = parseMul();
924
1110
  while (isOp("+", "-")) {
925
- const op = eat().v, r = parseMul();
926
- l = op === "+" ? toNum(l) + toNum(r) : toNum(l) - toNum(r);
1111
+ const op2 = eat().v, r = parseMul();
1112
+ l = op2 === "+" ? toNum(l) + toNum(r) : toNum(l) - toNum(r);
927
1113
  }
928
1114
  return l;
929
1115
  }
930
1116
  function parseMul() {
931
1117
  let l = parseUnary();
932
1118
  while (isOp("*", "/", "%")) {
933
- const op = eat().v, r = parseUnary();
1119
+ const op2 = eat().v, r = parseUnary();
934
1120
  const a = toNum(l), b = toNum(r);
935
- l = op === "*" ? a * b : op === "/" ? a / b : a % b;
1121
+ l = op2 === "*" ? a * b : op2 === "/" ? a / b : a % b;
936
1122
  }
937
1123
  return l;
938
1124
  }
@@ -1016,7 +1202,7 @@ function evaluateFormula(expr, getField) {
1016
1202
  case "ISEMPTY":
1017
1203
  return isBlank(args[0]) ? 1 : 0;
1018
1204
  case "DAYS": {
1019
- const a = isoDate(args[0]), b = isoDate(args[1]);
1205
+ const a = isoDate2(args[0]), b = isoDate2(args[1]);
1020
1206
  return a && b ? Math.round((dayNumber(a) - dayNumber(b)) / 864e5) : null;
1021
1207
  }
1022
1208
  default:
@@ -1198,6 +1384,156 @@ function cleanPlacementFilterDefaults(defaults, allowedKeys) {
1198
1384
  return Object.keys(out).length > 0 ? out : void 0;
1199
1385
  }
1200
1386
 
1387
+ // ../shared/src/formulaBuilder.ts
1388
+ var FORMULA_TYPE_LABELS = {
1389
+ NUMBER: "\u05DE\u05E1\u05E4\u05E8",
1390
+ CURRENCY: "\u05DE\u05D8\u05D1\u05E2",
1391
+ STRING: "\u05D8\u05E7\u05E1\u05D8",
1392
+ PHONE: "\u05D8\u05DC\u05E4\u05D5\u05DF",
1393
+ TIME: "\u05E9\u05E2\u05D4",
1394
+ DATE: "\u05EA\u05D0\u05E8\u05D9\u05DA",
1395
+ BOOLEAN: "\u05DB\u05DF/\u05DC\u05D0"
1396
+ };
1397
+ var FORMULA_OPERATOR_GROUPS = [
1398
+ {
1399
+ label: "\u05D7\u05E9\u05D1\u05D5\u05DF",
1400
+ items: [
1401
+ { label: "+ \u05D7\u05D9\u05D1\u05D5\u05E8", insert: " + " },
1402
+ { label: "- \u05D7\u05D9\u05E1\u05D5\u05E8", insert: " - " },
1403
+ { label: "* \u05DB\u05E4\u05DC", insert: " * " },
1404
+ { label: "/ \u05D7\u05D9\u05DC\u05D5\u05E7", insert: " / " },
1405
+ { label: "% \u05E9\u05D0\u05E8\u05D9\u05EA", insert: " % " }
1406
+ ]
1407
+ },
1408
+ {
1409
+ label: "\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4",
1410
+ items: [
1411
+ { label: "= \u05E9\u05D5\u05D5\u05D4", insert: " = " },
1412
+ { label: "<> \u05E9\u05D5\u05E0\u05D4", insert: " <> " },
1413
+ { label: "> \u05D2\u05D3\u05D5\u05DC \u05DE", insert: " > " },
1414
+ { label: "< \u05E7\u05D8\u05DF \u05DE", insert: " < " },
1415
+ { label: ">= \u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4", insert: " >= " },
1416
+ { label: "<= \u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4", insert: " <= " }
1417
+ ]
1418
+ },
1419
+ { label: "\u05D8\u05E7\u05E1\u05D8", items: [{ label: "& \u05D7\u05D9\u05D1\u05D5\u05E8 \u05D8\u05E7\u05E1\u05D8\u05D9\u05DD", insert: " & " }] },
1420
+ {
1421
+ label: "\u05E1\u05D9\u05DE\u05E0\u05D9\u05DD",
1422
+ items: [
1423
+ { label: "( \u05E4\u05EA\u05D9\u05D7\u05EA \u05E1\u05D5\u05D2\u05E8\u05D9\u05D9\u05DD", insert: "(" },
1424
+ { label: ") \u05E1\u05D2\u05D9\u05E8\u05EA \u05E1\u05D5\u05D2\u05E8\u05D9\u05D9\u05DD", insert: ")" },
1425
+ { label: ", \u05E4\u05E1\u05D9\u05E7 (\u05D1\u05D9\u05DF \u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD)", insert: ", " }
1426
+ ]
1427
+ }
1428
+ ];
1429
+ var FORMULA_FUNCTION_GROUPS = [
1430
+ {
1431
+ label: "\u05EA\u05E0\u05D0\u05D9\u05DD \u05D5\u05DC\u05D5\u05D2\u05D9\u05E7\u05D4",
1432
+ items: [
1433
+ { label: "\u05D0\u05DD... \u05D0\u05D6... \u05D0\u05D7\u05E8\u05EA (IF)", template: "IF(, , )" },
1434
+ { label: "\u05D5\u05D2\u05DD (AND)", template: "AND(, )" },
1435
+ { label: "\u05D0\u05D5 (OR)", template: "OR(, )" },
1436
+ { label: "\u05DC\u05D0 (NOT)", template: "NOT()" },
1437
+ { label: "\u05D4\u05D0\u05DD \u05E8\u05D9\u05E7 (ISEMPTY)", template: "ISEMPTY()" }
1438
+ ]
1439
+ },
1440
+ {
1441
+ label: "\u05D8\u05E7\u05E1\u05D8",
1442
+ items: [
1443
+ { label: "\u05DE\u05DB\u05D9\u05DC \u05D8\u05E7\u05E1\u05D8 (CONTAINS)", template: 'CONTAINS(, "")' },
1444
+ { label: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1 (STARTSWITH)", template: 'STARTSWITH(, "")' },
1445
+ { label: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 (ENDSWITH)", template: 'ENDSWITH(, "")' }
1446
+ ]
1447
+ },
1448
+ {
1449
+ label: "\u05DE\u05E1\u05E4\u05E8\u05D9\u05DD",
1450
+ items: [
1451
+ { label: "\u05E2\u05D9\u05D2\u05D5\u05DC (ROUND)", template: "ROUND(, 2)" },
1452
+ { label: "\u05DE\u05D9\u05E0\u05D9\u05DE\u05D5\u05DD (MIN)", template: "MIN(, )" },
1453
+ { label: "\u05DE\u05E7\u05E1\u05D9\u05DE\u05D5\u05DD (MAX)", template: "MAX(, )" },
1454
+ { label: "\u05E2\u05E8\u05DA \u05DE\u05D5\u05D7\u05DC\u05D8 (ABS)", template: "ABS()" }
1455
+ ]
1456
+ },
1457
+ {
1458
+ label: "\u05EA\u05D0\u05E8\u05D9\u05DB\u05D9\u05DD",
1459
+ items: [{ label: "\u05D4\u05E4\u05E8\u05E9 \u05D9\u05DE\u05D9\u05DD (DAYS: \u05E1\u05D5\u05E3, \u05D4\u05EA\u05D7\u05DC\u05D4)", template: "DAYS(, )" }]
1460
+ }
1461
+ ];
1462
+ var NUMBER_RE = /^-?\d+(\.\d+)?$/;
1463
+ var isFieldRef = (s) => s.startsWith("{") && s.endsWith("}");
1464
+ var quote = (s) => `"${s.replace(/"/g, "")}"`;
1465
+ var literal = (raw, forceText) => {
1466
+ const v = raw.trim();
1467
+ if (isFieldRef(v)) return v;
1468
+ if (!forceText && NUMBER_RE.test(v)) return v;
1469
+ return quote(v);
1470
+ };
1471
+ var operand = (raw) => {
1472
+ const v = raw.trim();
1473
+ if (v === "") return '""';
1474
+ if (isFieldRef(v) || NUMBER_RE.test(v)) return v;
1475
+ return quote(v);
1476
+ };
1477
+ var cmp = (id, label, sym) => ({
1478
+ id,
1479
+ label,
1480
+ needsValue: true,
1481
+ build: (f, v, t) => `${f} ${sym} ${literal(v, t)}`
1482
+ });
1483
+ var EMPTY_OPS2 = [
1484
+ { id: "empty", label: "\u05E8\u05D9\u05E7", needsValue: false, build: (f) => `ISEMPTY(${f})` },
1485
+ { id: "notempty", label: "\u05DC\u05D0 \u05E8\u05D9\u05E7", needsValue: false, build: (f) => `NOT(ISEMPTY(${f}))` }
1486
+ ];
1487
+ var NUMBER_OPS = [
1488
+ cmp("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC", "="),
1489
+ cmp("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE", "<>"),
1490
+ cmp("gt", "\u05D2\u05D3\u05D5\u05DC \u05DE", ">"),
1491
+ cmp("lt", "\u05E7\u05D8\u05DF \u05DE", "<"),
1492
+ cmp("ge", "\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC", ">="),
1493
+ cmp("le", "\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC", "<="),
1494
+ ...EMPTY_OPS2
1495
+ ];
1496
+ var DATE_OPS = [
1497
+ cmp("eq", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA", "="),
1498
+ cmp("ne", "\u05DC\u05D0 \u05D1\u05EA\u05D0\u05E8\u05D9\u05DA", "<>"),
1499
+ cmp("gt", "\u05D0\u05D7\u05E8\u05D9", ">"),
1500
+ cmp("lt", "\u05DC\u05E4\u05E0\u05D9", "<"),
1501
+ cmp("ge", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05D0\u05D7\u05E8\u05D9\u05D5", ">="),
1502
+ cmp("le", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05DC\u05E4\u05E0\u05D9\u05D5", "<="),
1503
+ ...EMPTY_OPS2
1504
+ ];
1505
+ var TEXT_OPS = [
1506
+ cmp("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC", "="),
1507
+ cmp("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE", "<>"),
1508
+ { id: "contains", label: "\u05DE\u05DB\u05D9\u05DC", needsValue: true, build: (f, v) => `CONTAINS(${f}, ${literal(v, true)})` },
1509
+ { id: "starts", label: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1", needsValue: true, build: (f, v) => `STARTSWITH(${f}, ${literal(v, true)})` },
1510
+ { id: "ends", label: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1", needsValue: true, build: (f, v) => `ENDSWITH(${f}, ${literal(v, true)})` },
1511
+ ...EMPTY_OPS2
1512
+ ];
1513
+ var BOOL_OPS = [
1514
+ { id: "yes", label: "\u05DE\u05E1\u05D5\u05DE\u05DF (\u05DB\u05DF)", needsValue: false, build: (f) => `${f} = 1` },
1515
+ { id: "no", label: "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF (\u05DC\u05D0)", needsValue: false, build: (f) => `${f} = 0` }
1516
+ ];
1517
+ var opsOf = (type) => type === "NUMBER" || type === "CURRENCY" ? NUMBER_OPS : type === "DATE" ? DATE_OPS : type === "BOOLEAN" ? BOOL_OPS : TEXT_OPS;
1518
+ var isTextual = (type) => !(type === "NUMBER" || type === "CURRENCY");
1519
+ var EMPTY_IF_CONDITION = { field: "", op: "", value: "" };
1520
+ var getIfConditionOps = (type) => opsOf(type).map(({ id, label, needsValue }) => ({ id, label, needsValue }));
1521
+ function buildIfConditionExpression(columns, c) {
1522
+ const col = columns.find((x) => x.name === c.field);
1523
+ if (!col) return null;
1524
+ const op2 = opsOf(col.type).find((o) => o.id === c.op);
1525
+ if (!op2) return null;
1526
+ if (op2.needsValue && !c.value.trim()) return null;
1527
+ return op2.build(`{${col.name}}`, c.value.trim(), isTextual(col.type));
1528
+ }
1529
+ function buildIfExpression(columns, conds, joiner, thenVal, elseVal) {
1530
+ const parts = conds.map((c) => buildIfConditionExpression(columns, c));
1531
+ if (parts.some((p) => p === null)) return { error: "\u05D9\u05E9 \u05DC\u05D4\u05E9\u05DC\u05D9\u05DD \u05D1\u05DB\u05DC \u05EA\u05E0\u05D0\u05D9: \u05E9\u05D3\u05D4, \u05E4\u05E2\u05D5\u05DC\u05D4 \u05D5\u05E2\u05E8\u05DA" };
1532
+ const condText = parts.length === 1 ? parts[0] : `${joiner}(${parts.join(", ")})`;
1533
+ if (thenVal === void 0 || elseVal === void 0) return { expression: condText };
1534
+ return { expression: `IF(${condText}, ${operand(thenVal)}, ${operand(elseVal)})` };
1535
+ }
1536
+
1201
1537
  // src/components/TableBlock/TableBlockClient.tsx
1202
1538
  import React14, { useState as useState16, useMemo as useMemo8, useEffect as useEffect14, useCallback as useCallback12, useRef as useRef14 } from "react";
1203
1539
 
@@ -3857,6 +4193,8 @@ var NUMERIC = ["NUMBER", "CURRENCY"];
3857
4193
  var OPS = ["+", "-", "*", "/", "(", ")"];
3858
4194
  var selCls = "w-full px-2 py-1 border border-slate-300 rounded text-sm bg-white";
3859
4195
  var lblCls = "block text-[11px] text-slate-600 mb-0.5";
4196
+ var smallBtn = "px-2 py-1 text-xs rounded border border-slate-300 bg-white hover:bg-slate-100";
4197
+ var typeLabel = (t) => FORMULA_TYPE_LABELS[t] || (t === "RELATION" ? "\u05E7\u05E9\u05E8" : t === "FORMULA" ? "\u05E0\u05D5\u05E1\u05D7\u05D4" : t);
3860
4198
  var RecordPicker = ({ tableId, executeAction, value, onPick }) => {
3861
4199
  const [q, setQ] = useState8("");
3862
4200
  const [options, setOptions] = useState8([]);
@@ -3904,7 +4242,88 @@ var RecordPicker = ({ tableId, executeAction, value, onPick }) => {
3904
4242
  )
3905
4243
  ] });
3906
4244
  };
3907
- var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear, onClose }) => {
4245
+ var FilterEditor = ({ columns, conds, join, onChange }) => {
4246
+ const update = (i, patch) => onChange(conds.map((c, idx) => idx === i ? __spreadValues(__spreadValues({}, c), patch) : c), join);
4247
+ return /* @__PURE__ */ jsxs8("div", { className: "space-y-1.5 pt-1.5 border-t border-slate-200", children: [
4248
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05E1\u05D9\u05E0\u05D5\u05DF: \u05DC\u05E1\u05DB\u05DD \u05E8\u05E7 \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05E9\u05E2\u05D5\u05DE\u05D3\u05D5\u05EA \u05D1\u05EA\u05E0\u05D0\u05D9 (\u05DC\u05D0 \u05D7\u05D5\u05D1\u05D4)" }),
4249
+ conds.map((c, i) => {
4250
+ const col = columns.find((x) => x.name === c.field);
4251
+ const ops = col ? getFilterOps(col.type) : [];
4252
+ const op2 = ops.find((o) => o.id === c.op);
4253
+ const kind = filterKindOfType(col == null ? void 0 : col.type);
4254
+ return /* @__PURE__ */ jsxs8("div", { className: "space-y-1 p-1.5 rounded bg-white border border-slate-200", children: [
4255
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
4256
+ /* @__PURE__ */ jsx8("span", { className: "text-[11px] font-medium text-slate-600", children: i === 0 ? "\u05E8\u05E7 \u05D0\u05DD" : join === "AND" ? "\u05D5\u05D2\u05DD" : "\u05D0\u05D5" }),
4257
+ /* @__PURE__ */ jsx8(
4258
+ "button",
4259
+ {
4260
+ type: "button",
4261
+ className: "text-[11px] text-rose-600 hover:underline",
4262
+ onClick: () => onChange(conds.filter((_, idx) => idx !== i), join),
4263
+ children: "\u05D4\u05E1\u05E8"
4264
+ }
4265
+ )
4266
+ ] }),
4267
+ /* @__PURE__ */ jsxs8(
4268
+ "select",
4269
+ {
4270
+ className: selCls,
4271
+ value: c.field,
4272
+ onChange: (e) => update(i, { field: e.target.value, op: "", value: "" }),
4273
+ children: [
4274
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E9\u05D3\u05D4 --" }),
4275
+ columns.map((x) => /* @__PURE__ */ jsxs8("option", { value: x.name, children: [
4276
+ x.name,
4277
+ " (",
4278
+ typeLabel(x.type),
4279
+ ")"
4280
+ ] }, x.name))
4281
+ ]
4282
+ }
4283
+ ),
4284
+ col && /* @__PURE__ */ jsxs8("select", { className: selCls, value: c.op, onChange: (e) => update(i, { op: e.target.value, value: "" }), children: [
4285
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E4\u05E2\u05D5\u05DC\u05D4 --" }),
4286
+ ops.map((o) => /* @__PURE__ */ jsx8("option", { value: o.id, children: o.label }, o.id))
4287
+ ] }),
4288
+ (op2 == null ? void 0 : op2.needsValue) && /* @__PURE__ */ jsx8(
4289
+ "input",
4290
+ {
4291
+ className: selCls,
4292
+ type: kind === "date" ? "date" : "text",
4293
+ value: c.value,
4294
+ onChange: (e) => update(i, { value: e.target.value }),
4295
+ placeholder: kind === "relation" ? "\u05D4\u05E2\u05E8\u05DA \u05DB\u05E4\u05D9 \u05E9\u05DE\u05D5\u05E6\u05D2 \u05D1\u05D8\u05D1\u05DC\u05D4" : "\u05E2\u05E8\u05DA \u05DC\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4"
4296
+ }
4297
+ )
4298
+ ] }, i);
4299
+ }),
4300
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
4301
+ /* @__PURE__ */ jsx8(
4302
+ "button",
4303
+ {
4304
+ type: "button",
4305
+ disabled: conds.length >= MAX_FILTER_CONDITIONS,
4306
+ className: smallBtn,
4307
+ onClick: () => onChange([...conds, { field: "", op: "", value: "" }], join),
4308
+ children: "+ \u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9 \u05E1\u05D9\u05E0\u05D5\u05DF"
4309
+ }
4310
+ ),
4311
+ conds.length > 1 && /* @__PURE__ */ jsxs8(
4312
+ "select",
4313
+ {
4314
+ className: "px-2 py-1 border border-slate-300 rounded text-xs bg-white",
4315
+ value: join,
4316
+ onChange: (e) => onChange(conds, e.target.value),
4317
+ children: [
4318
+ /* @__PURE__ */ jsx8("option", { value: "AND", children: "\u05DB\u05DC \u05D4\u05EA\u05E0\u05D0\u05D9\u05DD (\u05D5\u05D2\u05DD)" }),
4319
+ /* @__PURE__ */ jsx8("option", { value: "OR", children: "\u05DC\u05E4\u05D7\u05D5\u05EA \u05D0\u05D7\u05D3 (\u05D0\u05D5)" })
4320
+ ]
4321
+ }
4322
+ )
4323
+ ] })
4324
+ ] });
4325
+ };
4326
+ var CellFormulaEditor = ({ initial, rowColumns, context, anchor, onApply, onClear, onClose }) => {
3908
4327
  const executeAction = context == null ? void 0 : context.executeAction;
3909
4328
  const taRef = useRef8(null);
3910
4329
  const [expression, setExpression] = useState8((initial == null ? void 0 : initial.expression) || "");
@@ -3917,6 +4336,13 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
3917
4336
  const [rec, setRec] = useState8({ id: "", label: "" });
3918
4337
  const [fld, setFld] = useState8("");
3919
4338
  const [agg, setAgg] = useState8("SUM");
4339
+ const [fConds, setFConds] = useState8([]);
4340
+ const [fJoin, setFJoin] = useState8("AND");
4341
+ const [ifConds, setIfConds] = useState8([__spreadValues({}, EMPTY_IF_CONDITION)]);
4342
+ const [ifJoin, setIfJoin] = useState8("AND");
4343
+ const [thenVal, setThenVal] = useState8("");
4344
+ const [elseVal, setElseVal] = useState8("");
4345
+ const [builderError, setBuilderError] = useState8("");
3920
4346
  useEffect7(() => {
3921
4347
  (async () => {
3922
4348
  var _a, _b;
@@ -3931,8 +4357,11 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
3931
4357
  })();
3932
4358
  }, [executeAction]);
3933
4359
  const table = tables == null ? void 0 : tables.find((t) => t.id === tId);
3934
- const tableFields = ((table == null ? void 0 : table.columns) || []).filter((c) => panel === "agg" ? NUMERIC.includes(c.type) : true);
3935
- const insert = (text2) => {
4360
+ const valueFields = ((table == null ? void 0 : table.columns) || []).filter(
4361
+ (c) => FORMULA_SOURCE_TYPES.includes(c.type) && (panel === "agg" ? NUMERIC.includes(c.type) : true)
4362
+ );
4363
+ const rowFieldNames = useMemo4(() => rowColumns.map((c) => c.name), [rowColumns]);
4364
+ const insert = (text2, caret) => {
3936
4365
  var _a, _b;
3937
4366
  const el = taRef.current;
3938
4367
  const s = (_a = el == null ? void 0 : el.selectionStart) != null ? _a : expression.length;
@@ -3940,38 +4369,53 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
3940
4369
  const next = expression.slice(0, s) + text2 + expression.slice(e);
3941
4370
  setExpression(next);
3942
4371
  setError("");
4372
+ const pos = s + (caret != null ? caret : text2.length);
3943
4373
  requestAnimationFrame(() => {
3944
4374
  el == null ? void 0 : el.focus();
3945
- const p = s + text2.length;
3946
- el == null ? void 0 : el.setSelectionRange(p, p);
4375
+ el == null ? void 0 : el.setSelectionRange(pos, pos);
3947
4376
  });
3948
4377
  };
4378
+ const readFilter = () => {
4379
+ const started = fConds.filter((c) => c.field || c.op || c.value);
4380
+ const filter = sanitizeRefFilter({ join: fJoin, conditions: started });
4381
+ const incomplete = started.length > 0 && (!filter || filter.conditions.length !== started.length);
4382
+ return { filter, incomplete };
4383
+ };
3949
4384
  const addRef = () => {
3950
4385
  if (!table || !fld) return;
3951
4386
  if (panel === "cell" && !rec.id) return;
3952
4387
  const isAgg = panel === "agg";
3953
- const same = refs.find((r) => r.tableId === table.id && r.field === fld && (isAgg ? r.agg === agg : !r.agg && r.recordId === rec.id));
4388
+ const { filter, incomplete } = isAgg ? readFilter() : { filter: null, incomplete: false };
4389
+ if (incomplete) {
4390
+ setError("\u05D9\u05E9 \u05DC\u05D4\u05E9\u05DC\u05D9\u05DD \u05D1\u05DB\u05DC \u05EA\u05E0\u05D0\u05D9 \u05E1\u05D9\u05E0\u05D5\u05DF: \u05E9\u05D3\u05D4, \u05E4\u05E2\u05D5\u05DC\u05D4 \u05D5\u05E2\u05E8\u05DA (\u05D0\u05D5 \u05DC\u05D4\u05E1\u05D9\u05E8 \u05D0\u05D5\u05EA\u05D5)");
4391
+ return;
4392
+ }
4393
+ const sig = filterSignature(filter);
4394
+ const same = refs.find((r) => r.tableId === table.id && r.field === fld && (isAgg ? r.agg === agg && filterSignature(r.filter) === sig : !r.agg && r.recordId === rec.id));
3954
4395
  let key;
3955
4396
  if (same) key = same.key;
3956
4397
  else {
3957
4398
  key = makeCellRefKey(refs, fld, isAgg ? agg : void 0);
3958
- setRefs((prev) => [...prev, __spreadValues({
4399
+ setRefs((prev) => [...prev, __spreadValues(__spreadValues({
3959
4400
  key,
3960
4401
  tableId: table.id,
3961
4402
  tableName: table.name,
3962
4403
  recordId: isAgg ? "" : rec.id,
3963
4404
  recordLabel: isAgg ? "" : rec.label,
3964
4405
  field: fld
3965
- }, isAgg ? { agg } : {})]);
4406
+ }, isAgg ? { agg } : {}), isAgg && filter ? { filter } : {})]);
3966
4407
  }
3967
4408
  insert(`{${key}}`);
4409
+ setError("");
3968
4410
  setPanel("");
3969
4411
  setFld("");
4412
+ setFConds([]);
3970
4413
  };
3971
4414
  const used = useMemo4(() => new Set(extractFormulaFields(expression)), [expression]);
3972
4415
  const usedRefs = refs.filter((r) => used.has(r.key));
4416
+ const live = expression.trim() ? validateFormula(expression, [...rowFieldNames, ...refs.map((r) => r.key)]) : null;
3973
4417
  const apply = () => {
3974
- const err = validateFormula(expression, [...rowFields, ...refs.map((r) => r.key)]);
4418
+ const err = validateFormula(expression, [...rowFieldNames, ...refs.map((r) => r.key)]);
3975
4419
  if (err) {
3976
4420
  setError(err);
3977
4421
  return;
@@ -3983,7 +4427,28 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
3983
4427
  setTId("");
3984
4428
  setFld("");
3985
4429
  setRec({ id: "", label: "" });
4430
+ setFConds([]);
4431
+ setError("");
3986
4432
  };
4433
+ const updateIfCond = (i, patch) => setIfConds((prev) => prev.map((c, idx) => idx === i ? __spreadValues(__spreadValues({}, c), patch) : c));
4434
+ const insertBuilt = (withIf) => {
4435
+ const res = withIf ? buildIfExpression(rowColumns, ifConds, ifJoin, thenVal, elseVal) : buildIfExpression(rowColumns, ifConds, ifJoin);
4436
+ if ("error" in res) {
4437
+ setBuilderError(res.error);
4438
+ return;
4439
+ }
4440
+ setBuilderError("");
4441
+ insert(res.expression);
4442
+ };
4443
+ const rowFieldOptions = /* @__PURE__ */ jsxs8(Fragment3, { children: [
4444
+ /* @__PURE__ */ jsx8("option", { value: "", children: rowColumns.length === 0 ? "-- \u05D0\u05D9\u05DF \u05E9\u05D3\u05D5\u05EA \u05DE\u05EA\u05D0\u05D9\u05DE\u05D9\u05DD \u05D1\u05D8\u05D1\u05DC\u05D4 \u05D4\u05D6\u05D5 --" : "-- \u05D1\u05D7\u05E8 \u05E9\u05D3\u05D4 --" }),
4445
+ rowColumns.map((c) => /* @__PURE__ */ jsxs8("option", { value: c.name, children: [
4446
+ c.name,
4447
+ " (",
4448
+ typeLabel(c.type),
4449
+ ")"
4450
+ ] }, c.name))
4451
+ ] });
3987
4452
  return createPortal3(
3988
4453
  /* @__PURE__ */ jsxs8(Fragment3, { children: [
3989
4454
  /* @__PURE__ */ jsx8("div", { className: "fixed inset-0 z-[9998]", onClick: onClose }),
@@ -3991,7 +4456,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
3991
4456
  "div",
3992
4457
  {
3993
4458
  dir: "rtl",
3994
- className: "fixed z-[9999] w-[340px] max-h-[80vh] overflow-auto p-3 bg-white border border-slate-200 rounded-lg shadow-xl space-y-2",
4459
+ className: "fixed z-[9999] w-[380px] max-h-[85vh] overflow-auto p-3 bg-white border border-slate-200 rounded-lg shadow-xl space-y-2",
3995
4460
  style: { top: anchor.top, left: anchor.left },
3996
4461
  children: [
3997
4462
  /* @__PURE__ */ jsx8("div", { className: "text-sm font-semibold text-slate-700", children: "\u05E0\u05D5\u05E1\u05D7\u05D4 \u05DC\u05EA\u05D0" }),
@@ -4000,7 +4465,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4000
4465
  {
4001
4466
  ref: taRef,
4002
4467
  dir: "ltr",
4003
- rows: 2,
4468
+ rows: 3,
4004
4469
  value: expression,
4005
4470
  onChange: (e) => {
4006
4471
  setExpression(e.target.value);
@@ -4010,6 +4475,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4010
4475
  className: "w-full px-2 py-1.5 border border-slate-300 rounded text-sm font-mono bg-white"
4011
4476
  }
4012
4477
  ),
4478
+ live && /* @__PURE__ */ jsx8("div", { className: "text-[11px] text-rose-500", children: live }),
4013
4479
  usedRefs.length > 0 && /* @__PURE__ */ jsx8("div", { className: "flex flex-wrap gap-1", children: usedRefs.map((r) => /* @__PURE__ */ jsxs8(
4014
4480
  "span",
4015
4481
  {
@@ -4021,11 +4487,55 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4021
4487
  /* @__PURE__ */ jsxs8("span", { className: "text-slate-400", children: [
4022
4488
  "\xB7 ",
4023
4489
  r.tableName
4490
+ ] }),
4491
+ r.filter && /* @__PURE__ */ jsxs8("span", { className: "text-amber-600", children: [
4492
+ " \xB7 ",
4493
+ describeRefFilter(r.filter)
4024
4494
  ] })
4025
4495
  ]
4026
4496
  },
4027
4497
  r.key
4028
4498
  )) }),
4499
+ /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-3 gap-1.5", children: [
4500
+ /* @__PURE__ */ jsxs8("div", { children: [
4501
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05E9\u05D3\u05D4" }),
4502
+ /* @__PURE__ */ jsx8(
4503
+ "select",
4504
+ {
4505
+ className: selCls,
4506
+ value: "",
4507
+ disabled: rowColumns.length === 0,
4508
+ onChange: (e) => e.target.value && insert(`{${e.target.value}}`),
4509
+ children: rowFieldOptions
4510
+ }
4511
+ )
4512
+ ] }),
4513
+ /* @__PURE__ */ jsxs8("div", { children: [
4514
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05D0\u05D5\u05E4\u05E8\u05D8\u05D5\u05E8" }),
4515
+ /* @__PURE__ */ jsxs8("select", { className: selCls, value: "", onChange: (e) => e.target.value && insert(e.target.value), children: [
4516
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 --" }),
4517
+ FORMULA_OPERATOR_GROUPS.map((g) => /* @__PURE__ */ jsx8("optgroup", { label: g.label, children: g.items.map((it) => /* @__PURE__ */ jsx8("option", { value: it.insert, children: it.label }, it.label)) }, g.label))
4518
+ ] })
4519
+ ] }),
4520
+ /* @__PURE__ */ jsxs8("div", { children: [
4521
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4" }),
4522
+ /* @__PURE__ */ jsxs8(
4523
+ "select",
4524
+ {
4525
+ className: selCls,
4526
+ value: "",
4527
+ onChange: (e) => {
4528
+ const tpl = e.target.value;
4529
+ if (tpl) insert(tpl, tpl.indexOf("(") + 1);
4530
+ },
4531
+ children: [
4532
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 --" }),
4533
+ FORMULA_FUNCTION_GROUPS.map((g) => /* @__PURE__ */ jsx8("optgroup", { label: g.label, children: g.items.map((it) => /* @__PURE__ */ jsx8("option", { value: it.template, children: it.label }, it.label)) }, g.label))
4534
+ ]
4535
+ }
4536
+ )
4537
+ ] })
4538
+ ] }),
4029
4539
  /* @__PURE__ */ jsx8("div", { className: "flex items-center gap-1", style: { direction: "ltr" }, children: OPS.map((o) => /* @__PURE__ */ jsx8(
4030
4540
  "button",
4031
4541
  {
@@ -4036,13 +4546,6 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4036
4546
  },
4037
4547
  o
4038
4548
  )) }),
4039
- rowFields.length > 0 && /* @__PURE__ */ jsxs8("div", { children: [
4040
- /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05E9\u05D3\u05D4 \u05DE\u05D0\u05D5\u05EA\u05D4 \u05E9\u05D5\u05E8\u05D4" }),
4041
- /* @__PURE__ */ jsxs8("select", { className: selCls, value: "", onChange: (e) => e.target.value && insert(`{${e.target.value}}`), children: [
4042
- /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D4\u05D5\u05E1\u05E3 \u05E9\u05D3\u05D4 --" }),
4043
- rowFields.map((f) => /* @__PURE__ */ jsx8("option", { value: f, children: f }, f))
4044
- ] })
4045
- ] }),
4046
4549
  /* @__PURE__ */ jsxs8("div", { className: "flex gap-1.5", children: [
4047
4550
  /* @__PURE__ */ jsx8(
4048
4551
  "button",
@@ -4069,14 +4572,23 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4069
4572
  tables && /* @__PURE__ */ jsxs8(Fragment3, { children: [
4070
4573
  /* @__PURE__ */ jsxs8("div", { children: [
4071
4574
  /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D8\u05D1\u05DC\u05D4" }),
4072
- /* @__PURE__ */ jsxs8("select", { className: selCls, value: tId, onChange: (e) => {
4073
- setTId(e.target.value);
4074
- setFld("");
4075
- setRec({ id: "", label: "" });
4076
- }, children: [
4077
- /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05D8\u05D1\u05DC\u05D4 --" }),
4078
- tables.filter((t) => panel === "cell" || t.columns.some((c) => NUMERIC.includes(c.type))).map((t) => /* @__PURE__ */ jsx8("option", { value: t.id, children: t.name }, t.id))
4079
- ] })
4575
+ /* @__PURE__ */ jsxs8(
4576
+ "select",
4577
+ {
4578
+ className: selCls,
4579
+ value: tId,
4580
+ onChange: (e) => {
4581
+ setTId(e.target.value);
4582
+ setFld("");
4583
+ setRec({ id: "", label: "" });
4584
+ setFConds([]);
4585
+ },
4586
+ children: [
4587
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05D8\u05D1\u05DC\u05D4 --" }),
4588
+ tables.filter((t) => panel === "cell" || t.columns.some((c) => NUMERIC.includes(c.type))).map((t) => /* @__PURE__ */ jsx8("option", { value: t.id, children: t.name }, t.id))
4589
+ ]
4590
+ }
4591
+ )
4080
4592
  ] }),
4081
4593
  panel === "cell" && tId && /* @__PURE__ */ jsxs8("div", { children: [
4082
4594
  /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05E8\u05E9\u05D5\u05DE\u05D4" }),
@@ -4094,13 +4606,26 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4094
4606
  /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05E2\u05DE\u05D5\u05D3\u05D4" }),
4095
4607
  /* @__PURE__ */ jsxs8("select", { className: selCls, value: fld, onChange: (e) => setFld(e.target.value), children: [
4096
4608
  /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E2\u05DE\u05D5\u05D3\u05D4 --" }),
4097
- tableFields.filter((c) => FORMULA_SOURCE_TYPES.includes(c.type)).map((c) => /* @__PURE__ */ jsx8("option", { value: c.name, children: c.name }, c.name))
4609
+ valueFields.map((c) => /* @__PURE__ */ jsx8("option", { value: c.name, children: c.name }, c.name))
4098
4610
  ] })
4099
4611
  ] }),
4100
4612
  panel === "agg" && /* @__PURE__ */ jsxs8("div", { children: [
4101
4613
  /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05E4\u05E2\u05D5\u05DC\u05D4" }),
4102
4614
  /* @__PURE__ */ jsx8("select", { className: selCls, value: agg, onChange: (e) => setAgg(e.target.value), children: PER_RECORD_SOURCE_AGGS.map((a) => /* @__PURE__ */ jsx8("option", { value: a, children: PER_RECORD_AGG_LABELS[a] }, a)) })
4103
4615
  ] }),
4616
+ panel === "agg" && table && /* @__PURE__ */ jsx8(
4617
+ FilterEditor,
4618
+ {
4619
+ columns: table.columns.filter((c) => !String(c.name).startsWith("_")),
4620
+ conds: fConds,
4621
+ join: fJoin,
4622
+ onChange: (c, j) => {
4623
+ setFConds(c);
4624
+ setFJoin(j);
4625
+ setError("");
4626
+ }
4627
+ }
4628
+ ),
4104
4629
  /* @__PURE__ */ jsx8(
4105
4630
  "button",
4106
4631
  {
@@ -4113,6 +4638,138 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4113
4638
  )
4114
4639
  ] })
4115
4640
  ] }),
4641
+ /* @__PURE__ */ jsxs8("details", { className: "rounded border border-slate-200 bg-white", children: [
4642
+ /* @__PURE__ */ jsx8("summary", { className: "cursor-pointer select-none px-2 py-1.5 text-xs font-semibold text-slate-700", children: "\u05D1\u05D5\u05E0\u05D4 \u05EA\u05E0\u05D0\u05D9 (\u05D0\u05DD... \u05D0\u05D6... \u05D0\u05D7\u05E8\u05EA)" }),
4643
+ /* @__PURE__ */ jsxs8("div", { className: "p-2 space-y-2 border-t border-slate-200", children: [
4644
+ ifConds.map((c, i) => {
4645
+ const col = rowColumns.find((x) => x.name === c.field);
4646
+ const ops = col ? getIfConditionOps(col.type) : [];
4647
+ const op2 = ops.find((o) => o.id === c.op);
4648
+ return /* @__PURE__ */ jsxs8("div", { className: "space-y-1.5 p-2 rounded bg-slate-50 border border-slate-200", children: [
4649
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
4650
+ /* @__PURE__ */ jsx8("span", { className: "text-[11px] font-medium text-slate-600", children: i === 0 ? "\u05D0\u05DD" : ifJoin === "AND" ? "\u05D5\u05D2\u05DD" : "\u05D0\u05D5" }),
4651
+ ifConds.length > 1 && /* @__PURE__ */ jsx8(
4652
+ "button",
4653
+ {
4654
+ type: "button",
4655
+ className: "text-[11px] text-rose-600 hover:underline",
4656
+ onClick: () => setIfConds((prev) => prev.filter((_, idx) => idx !== i)),
4657
+ children: "\u05D4\u05E1\u05E8 \u05EA\u05E0\u05D0\u05D9"
4658
+ }
4659
+ )
4660
+ ] }),
4661
+ /* @__PURE__ */ jsx8(
4662
+ "select",
4663
+ {
4664
+ className: selCls,
4665
+ value: c.field,
4666
+ onChange: (e) => updateIfCond(i, { field: e.target.value, op: "", value: "" }),
4667
+ children: rowFieldOptions
4668
+ }
4669
+ ),
4670
+ col && /* @__PURE__ */ jsxs8("select", { className: selCls, value: c.op, onChange: (e) => updateIfCond(i, { op: e.target.value, value: "" }), children: [
4671
+ /* @__PURE__ */ jsx8("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E4\u05E2\u05D5\u05DC\u05D4 --" }),
4672
+ ops.map((o) => /* @__PURE__ */ jsx8("option", { value: o.id, children: o.label }, o.id))
4673
+ ] }),
4674
+ (op2 == null ? void 0 : op2.needsValue) && /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-2 gap-1.5", children: [
4675
+ /* @__PURE__ */ jsx8(
4676
+ "input",
4677
+ {
4678
+ type: (col == null ? void 0 : col.type) === "DATE" ? "date" : "text",
4679
+ value: c.value,
4680
+ onChange: (e) => updateIfCond(i, { value: e.target.value }),
4681
+ placeholder: "\u05E2\u05E8\u05DA \u05DC\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4",
4682
+ className: selCls
4683
+ }
4684
+ ),
4685
+ /* @__PURE__ */ jsxs8(
4686
+ "select",
4687
+ {
4688
+ className: selCls,
4689
+ value: "",
4690
+ onChange: (e) => e.target.value && updateIfCond(i, { value: `{${e.target.value}}` }),
4691
+ children: [
4692
+ /* @__PURE__ */ jsx8("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4 \u05D0\u05D7\u05E8" }),
4693
+ rowColumns.filter((s) => s.name !== c.field).map((s) => /* @__PURE__ */ jsx8("option", { value: s.name, children: s.name }, s.name))
4694
+ ]
4695
+ }
4696
+ )
4697
+ ] })
4698
+ ] }, i);
4699
+ }),
4700
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
4701
+ /* @__PURE__ */ jsx8(
4702
+ "button",
4703
+ {
4704
+ type: "button",
4705
+ disabled: ifConds.length >= 5,
4706
+ className: smallBtn,
4707
+ onClick: () => setIfConds((prev) => [...prev, __spreadValues({}, EMPTY_IF_CONDITION)]),
4708
+ children: "+ \u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9"
4709
+ }
4710
+ ),
4711
+ ifConds.length > 1 && /* @__PURE__ */ jsxs8(
4712
+ "select",
4713
+ {
4714
+ className: "px-2 py-1 border border-slate-300 rounded text-xs bg-white",
4715
+ value: ifJoin,
4716
+ onChange: (e) => setIfJoin(e.target.value),
4717
+ children: [
4718
+ /* @__PURE__ */ jsx8("option", { value: "AND", children: "\u05DB\u05DC \u05D4\u05EA\u05E0\u05D0\u05D9\u05DD (\u05D5\u05D2\u05DD)" }),
4719
+ /* @__PURE__ */ jsx8("option", { value: "OR", children: "\u05DC\u05E4\u05D7\u05D5\u05EA \u05D0\u05D7\u05D3 (\u05D0\u05D5)" })
4720
+ ]
4721
+ }
4722
+ )
4723
+ ] }),
4724
+ /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-2 gap-2", children: [
4725
+ /* @__PURE__ */ jsxs8("div", { children: [
4726
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D0\u05DD \u05D4\u05EA\u05E0\u05D0\u05D9 \u05DE\u05EA\u05E7\u05D9\u05D9\u05DD, \u05D4\u05EA\u05D5\u05E6\u05D0\u05D4:" }),
4727
+ /* @__PURE__ */ jsx8("input", { value: thenVal, onChange: (e) => setThenVal(e.target.value), placeholder: "\u05DE\u05E1\u05E4\u05E8, \u05D8\u05E7\u05E1\u05D8 \u05D0\u05D5 \u05E9\u05D3\u05D4", className: selCls }),
4728
+ /* @__PURE__ */ jsxs8(
4729
+ "select",
4730
+ {
4731
+ className: `${selCls} mt-1`,
4732
+ value: "",
4733
+ onChange: (e) => e.target.value && setThenVal(`{${e.target.value}}`),
4734
+ children: [
4735
+ /* @__PURE__ */ jsx8("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4" }),
4736
+ rowColumns.map((s) => /* @__PURE__ */ jsx8("option", { value: s.name, children: s.name }, s.name))
4737
+ ]
4738
+ }
4739
+ )
4740
+ ] }),
4741
+ /* @__PURE__ */ jsxs8("div", { children: [
4742
+ /* @__PURE__ */ jsx8("label", { className: lblCls, children: "\u05D0\u05D7\u05E8\u05EA, \u05D4\u05EA\u05D5\u05E6\u05D0\u05D4:" }),
4743
+ /* @__PURE__ */ jsx8("input", { value: elseVal, onChange: (e) => setElseVal(e.target.value), placeholder: "\u05DE\u05E1\u05E4\u05E8, \u05D8\u05E7\u05E1\u05D8 \u05D0\u05D5 \u05E9\u05D3\u05D4", className: selCls }),
4744
+ /* @__PURE__ */ jsxs8(
4745
+ "select",
4746
+ {
4747
+ className: `${selCls} mt-1`,
4748
+ value: "",
4749
+ onChange: (e) => e.target.value && setElseVal(`{${e.target.value}}`),
4750
+ children: [
4751
+ /* @__PURE__ */ jsx8("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4" }),
4752
+ rowColumns.map((s) => /* @__PURE__ */ jsx8("option", { value: s.name, children: s.name }, s.name))
4753
+ ]
4754
+ }
4755
+ )
4756
+ ] })
4757
+ ] }),
4758
+ builderError && /* @__PURE__ */ jsx8("p", { className: "text-[11px] text-rose-500", children: builderError }),
4759
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-2", children: [
4760
+ /* @__PURE__ */ jsx8(
4761
+ "button",
4762
+ {
4763
+ type: "button",
4764
+ onClick: () => insertBuilt(true),
4765
+ className: "px-3 py-1.5 text-xs rounded bg-slate-800 text-white hover:bg-slate-700",
4766
+ children: "\u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9 IF \u05DC\u05E0\u05D5\u05E1\u05D7\u05D4"
4767
+ }
4768
+ ),
4769
+ /* @__PURE__ */ jsx8("button", { type: "button", onClick: () => insertBuilt(false), className: smallBtn, children: "\u05D4\u05D5\u05E1\u05E3 \u05E8\u05E7 \u05D0\u05EA \u05D4\u05EA\u05E0\u05D0\u05D9" })
4770
+ ] })
4771
+ ] })
4772
+ ] }),
4116
4773
  error && /* @__PURE__ */ jsx8("div", { className: "text-xs text-red-600", children: error }),
4117
4774
  /* @__PURE__ */ jsxs8("div", { className: "flex gap-2 pt-1", children: [
4118
4775
  /* @__PURE__ */ jsx8(
@@ -4160,16 +4817,16 @@ var PerRecordSourceCell = ({ value, column, onChange, readOnly, context }) => {
4160
4817
  const btnRef = useRef8(null);
4161
4818
  const [open, setOpen] = useState8(false);
4162
4819
  const [pos, setPos] = useState8({ top: 0, left: 0 });
4163
- const rowFields = useMemo4(() => {
4820
+ const rowColumns = useMemo4(() => {
4164
4821
  const cols = Array.isArray(context == null ? void 0 : context.columns) ? context.columns : [];
4165
- return cols.filter((c) => (c == null ? void 0 : c.name) && c.name !== column.name && !String(c.name).startsWith("_") && FORMULA_SOURCE_TYPES.includes(String(c.type).toUpperCase())).map((c) => c.name);
4822
+ return cols.filter((c) => (c == null ? void 0 : c.name) && c.name !== column.name && !String(c.name).startsWith("_") && FORMULA_SOURCE_TYPES.includes(String(c.type).toUpperCase())).map((c) => ({ name: c.name, type: String(c.type).toUpperCase() }));
4166
4823
  }, [context == null ? void 0 : context.columns, column.name]);
4167
4824
  const openEditor = () => {
4168
4825
  var _a2;
4169
4826
  const r = (_a2 = btnRef.current) == null ? void 0 : _a2.getBoundingClientRect();
4170
4827
  if (r) {
4171
- const left = Math.max(8, Math.min(r.left, window.innerWidth - 356));
4172
- const top = Math.min(r.bottom + 4, Math.max(8, window.innerHeight - 420));
4828
+ const left = Math.max(8, Math.min(r.left, window.innerWidth - 396));
4829
+ const top = Math.min(r.bottom + 4, Math.max(8, window.innerHeight - 440));
4173
4830
  setPos({ top, left });
4174
4831
  }
4175
4832
  setOpen(true);
@@ -4192,7 +4849,7 @@ var PerRecordSourceCell = ({ value, column, onChange, readOnly, context }) => {
4192
4849
  CellFormulaEditor,
4193
4850
  {
4194
4851
  initial: current,
4195
- rowFields,
4852
+ rowColumns,
4196
4853
  context,
4197
4854
  anchor: pos,
4198
4855
  onClose: () => setOpen(false),
@@ -7060,12 +7717,12 @@ function TableBlockClient({
7060
7717
  setLocalColumns((prev) => mergeColumnDefs(prev, res.schema.columns));
7061
7718
  }
7062
7719
  if (res.records && Array.isArray(res.records)) {
7063
- const norm = normalizeRecords(res.records);
7720
+ const norm2 = normalizeRecords(res.records);
7064
7721
  const map = /* @__PURE__ */ new Map();
7065
- norm.forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7722
+ norm2.forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7066
7723
  setBaseRecordsMap(map);
7067
- setServerRecords(norm);
7068
- setData(mergeWithDirty(norm));
7724
+ setServerRecords(norm2);
7725
+ setData(mergeWithDirty(norm2));
7069
7726
  }
7070
7727
  if (res.meta) {
7071
7728
  const total = typeof res.meta.totalRecords === "number" ? res.meta.totalRecords : 0;
@@ -7101,13 +7758,13 @@ function TableBlockClient({
7101
7758
  }, [page, limit, debouncedSearch, filtersKey, fetchTableData, defaultFiltersReady]);
7102
7759
  useEffect14(() => {
7103
7760
  if (initialRecords && defaultFiltersReady) {
7104
- const norm = normalizeRecords(initialRecords);
7105
- setServerRecords(norm);
7761
+ const norm2 = normalizeRecords(initialRecords);
7762
+ setServerRecords(norm2);
7106
7763
  const hasActiveFilters = Boolean(debouncedSearch) || Object.keys(columnFilters).length > 0;
7107
7764
  if (hasActiveFilters && executeActionRef.current) {
7108
7765
  fetchTableData(page, limit, debouncedSearch, filtersKey);
7109
7766
  } else if (hasActiveFilters) {
7110
- let locallyFiltered = norm;
7767
+ let locallyFiltered = norm2;
7111
7768
  if (debouncedSearch) {
7112
7769
  const q = debouncedSearch.toLowerCase();
7113
7770
  locallyFiltered = locallyFiltered.filter(
@@ -7158,7 +7815,7 @@ function TableBlockClient({
7158
7815
  }
7159
7816
  setData(mergeWithDirty(locallyFiltered));
7160
7817
  } else {
7161
- setData(mergeWithDirty(norm));
7818
+ setData(mergeWithDirty(norm2));
7162
7819
  }
7163
7820
  }
7164
7821
  }, [initialRecords, mergeWithDirty, debouncedSearch, columnFilters, fetchTableData, page, limit, filtersKey, defaultFiltersReady]);
@@ -18135,9 +18792,14 @@ export {
18135
18792
  DEFAULT_PLACEMENT_STATUS_COLORS,
18136
18793
  DatePickerCell,
18137
18794
  DynamicFiltersBlock,
18795
+ EMPTY_IF_CONDITION,
18138
18796
  FORMULA_COLUMN_TYPE,
18797
+ FORMULA_FUNCTION_GROUPS,
18798
+ FORMULA_OPERATOR_GROUPS,
18139
18799
  FORMULA_SOURCE_TYPES,
18800
+ FORMULA_TYPE_LABELS,
18140
18801
  LinkPickerCell,
18802
+ MAX_FILTER_CONDITIONS,
18141
18803
  NON_TEXT_TYPES,
18142
18804
  PASTEL_PALETTES,
18143
18805
  PAYMENT_REPORTS_ACTIONS,
@@ -18173,6 +18835,8 @@ export {
18173
18835
  applyFormulaColumns,
18174
18836
  applyRelationCopy,
18175
18837
  buildColumnOptions,
18838
+ buildIfConditionExpression,
18839
+ buildIfExpression,
18176
18840
  buildRelationCopyPatch,
18177
18841
  buildRelationRef,
18178
18842
  calculateMinColumnWidth,
@@ -18182,11 +18846,14 @@ export {
18182
18846
  columnRefLabel,
18183
18847
  computeFormulaValue,
18184
18848
  describePerRecordFormula,
18849
+ describeRefFilter,
18185
18850
  enrichRowsWithRelations,
18186
18851
  evaluateFormula,
18187
18852
  extractFormulaFields,
18188
18853
  extractUniqueVariableIndices,
18189
18854
  extractVariableIndices,
18855
+ filterKindOfType,
18856
+ filterSignature,
18190
18857
  findVariableAtPosition,
18191
18858
  formatConflictCellValue,
18192
18859
  formatFileSize,
@@ -18198,6 +18865,8 @@ export {
18198
18865
  getDefaultFilterColumns,
18199
18866
  getDeterministicPastelBadge,
18200
18867
  getEligibleCopyTargets,
18868
+ getFilterOps,
18869
+ getIfConditionOps,
18201
18870
  getNextVariableIndex,
18202
18871
  getRelationButtonColumns,
18203
18872
  getRelationCopyLockedTargets,
@@ -18222,6 +18891,7 @@ export {
18222
18891
  isValidTemplateName,
18223
18892
  isWordToken,
18224
18893
  makeCellRefKey,
18894
+ matchesRefFilter,
18225
18895
  measureTextWidth,
18226
18896
  missingPaymentReportsFields,
18227
18897
  normalizePerRecordFormula,
@@ -18241,6 +18911,7 @@ export {
18241
18911
  resolveUniverseTheme,
18242
18912
  sanitizeDefaultFilter,
18243
18913
  sanitizePhoneNumber,
18914
+ sanitizeRefFilter,
18244
18915
  sanitizeTemplateNameInput,
18245
18916
  seamlessVariableEngine,
18246
18917
  splitHeaderTitle,