@gridkitjs/core 0.0.0-dev-20261109125321 → 0.0.0-dev-20261109130950

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.d.ts CHANGED
@@ -1142,6 +1142,13 @@ interface GridCommandHost {
1142
1142
  * The export command that asked then did not run.
1143
1143
  */
1144
1144
  readonly saveFile: ((file: ExportFile | Promise<ExportFile>) => void) | ((file: ExportFile | Promise<ExportFile>) => boolean);
1145
+ /**
1146
+ * Whether `saveFile` would save a file asked for now. An export command
1147
+ * asks first, and while it is `false` builds no file and does not run, so
1148
+ * a writer is never run for a file the host would drop. Left out, every
1149
+ * file can be saved.
1150
+ */
1151
+ readonly canSave?: (() => boolean) | undefined;
1145
1152
  /**
1146
1153
  * Puts a copy on the clipboard, as text and as HTML, and announces it —
1147
1154
  * `count` and `unit` say what to announce — or that the browser refused.
@@ -2601,6 +2608,7 @@ interface FilterEntryBase<Row> {
2601
2608
  }
2602
2609
  /** Matches a column's stringified value against an SQL LIKE-style query. */
2603
2610
  interface TextFilterEntry<Row> extends FilterEntryBase<Row> {
2611
+ readonly kind: "text";
2604
2612
  /**
2605
2613
  * A bare query is an exact match; `%text%` is contains; `text%` is
2606
2614
  * starts-with; `%text` is ends-with. Always case-insensitive. Only the
@@ -2620,6 +2628,7 @@ interface TextFilterEntry<Row> extends FilterEntryBase<Row> {
2620
2628
  * `TextFilterEntry` is that it doesn't do that.
2621
2629
  */
2622
2630
  interface ValueFilterEntry<Row> extends FilterEntryBase<Row> {
2631
+ readonly kind: "value";
2623
2632
  readonly value: number | boolean | Date;
2624
2633
  }
2625
2634
  type FilterPredicate<Row> = (value: unknown, row: Row) => boolean;
@@ -2631,6 +2640,7 @@ type FilterPredicate<Row> = (value: unknown, row: Row) => boolean;
2631
2640
  * the predicate is expected to read whatever it needs off `row` itself.
2632
2641
  */
2633
2642
  interface PredicateFilterEntry<Row> extends FilterEntryBase<Row> {
2643
+ readonly kind: "predicate";
2634
2644
  readonly predicate: FilterPredicate<Row>;
2635
2645
  }
2636
2646
  /**
@@ -2641,6 +2651,7 @@ interface PredicateFilterEntry<Row> extends FilterEntryBase<Row> {
2641
2651
  * to the entries it composes.
2642
2652
  */
2643
2653
  interface GroupFilterEntry<Row> {
2654
+ readonly kind: "group";
2644
2655
  readonly combinator: "and" | "or";
2645
2656
  readonly entries: FilterState<Row>;
2646
2657
  }
@@ -2677,10 +2688,12 @@ type FilterScalar = string | number | boolean | Date | null;
2677
2688
  * `ValueFilterEntry` of the wrong type doesn't.
2678
2689
  */
2679
2690
  interface OperatorFilterEntry<Row> {
2691
+ readonly kind: "operator";
2680
2692
  readonly columnId: FieldPath<Row> | (string & {});
2681
2693
  readonly operator: FilterOperator;
2682
2694
  readonly value?: FilterScalar | readonly FilterScalar[];
2683
2695
  }
2696
+ /** One condition of a `FilterState`, its `kind` naming which of the five. */
2684
2697
  type FilterEntry<Row> = TextFilterEntry<Row> | ValueFilterEntry<Row> | PredicateFilterEntry<Row> | OperatorFilterEntry<Row> | GroupFilterEntry<Row>;
2685
2698
  /**
2686
2699
  * The active filter, every entry ANDed together at the top level — nest a
@@ -2693,6 +2706,7 @@ type FilterState<Row> = readonly FilterEntry<Row>[];
2693
2706
  * string, which restoring turns back into a `Date`.
2694
2707
  */
2695
2708
  interface SerializedValueFilterEntry<Row> extends FilterEntryBase<Row> {
2709
+ readonly kind: "value";
2696
2710
  readonly value: number | boolean | string;
2697
2711
  }
2698
2712
  /** A `FilterScalar` as JSON holds it: a `Date` becomes its ISO string. */
@@ -2703,12 +2717,14 @@ type SerializedFilterScalar = string | number | boolean | null;
2703
2717
  * date, date-time or time column.
2704
2718
  */
2705
2719
  interface SerializedOperatorFilterEntry<Row> {
2720
+ readonly kind: "operator";
2706
2721
  readonly columnId: FieldPath<Row> | (string & {});
2707
2722
  readonly operator: FilterOperator;
2708
2723
  readonly value?: SerializedFilterScalar | readonly SerializedFilterScalar[];
2709
2724
  }
2710
2725
  /** A `GroupFilterEntry` whose entries are serialised too. */
2711
2726
  interface SerializedGroupFilterEntry<Row> {
2727
+ readonly kind: "group";
2712
2728
  readonly combinator: "and" | "or";
2713
2729
  readonly entries: SerializedFilterState<Row>;
2714
2730
  }
package/dist/index.js CHANGED
@@ -650,6 +650,175 @@ function compileOperatorEntry(entry, type) {
650
650
  }
651
651
  }
652
652
 
653
+ // src/util/filtering.ts
654
+ function parseFilterPattern(query) {
655
+ const start = query.startsWith("%");
656
+ const end = query.endsWith("%");
657
+ let text = query;
658
+ if (start) {
659
+ text = text.slice(1);
660
+ }
661
+ if (end) {
662
+ text = text.slice(0, -1);
663
+ }
664
+ text = text.toLowerCase();
665
+ if (start && end) {
666
+ return { mode: "contains", text };
667
+ }
668
+ if (start) {
669
+ return { mode: "endsWith", text };
670
+ }
671
+ if (end) {
672
+ return { mode: "startsWith", text };
673
+ }
674
+ return { mode: "exact", text };
675
+ }
676
+ function isEmptyValue(value) {
677
+ return value === null || value === void 0;
678
+ }
679
+ function compileFilterQuery(query) {
680
+ const { mode, text } = parseFilterPattern(query);
681
+ return (value) => {
682
+ const candidate = (isEmptyValue(value) ? "" : String(value)).toLowerCase();
683
+ switch (mode) {
684
+ case "exact":
685
+ return candidate === text;
686
+ case "contains":
687
+ return candidate.includes(text);
688
+ case "startsWith":
689
+ return candidate.startsWith(text);
690
+ case "endsWith":
691
+ return candidate.endsWith(text);
692
+ }
693
+ };
694
+ }
695
+ function matchesTypedValue(value, target, type) {
696
+ if (typeof target === "number") {
697
+ if (type !== "number" && type !== "decimal" && type !== "currency" && type !== "percent") {
698
+ return false;
699
+ }
700
+ return typeof value === "number" && value === target;
701
+ }
702
+ if (typeof target === "boolean") {
703
+ if (type !== "boolean") {
704
+ return false;
705
+ }
706
+ return typeof value === "boolean" && value === target;
707
+ }
708
+ if (type !== "date" && type !== "dateTime" && type !== "time") {
709
+ return false;
710
+ }
711
+ return value instanceof Date && value.getTime() === target.getTime();
712
+ }
713
+ function isEntryUsable(entry, byId) {
714
+ if (entry.kind === "group") {
715
+ return true;
716
+ }
717
+ return entry.columnId === void 0 || byId.has(entry.columnId);
718
+ }
719
+ function unknownFilterEntry(entry) {
720
+ const { kind } = entry;
721
+ throw new TypeError(
722
+ `GridKit: \`${String(kind)}\` is not a filter entry kind.`
723
+ );
724
+ }
725
+ function compileCellTest(columnId, byId, columns, test) {
726
+ if (columnId === void 0) {
727
+ return (row) => columns.some(
728
+ (entry) => test(accessDotted(row, entry.column.field), entry.column.type)
729
+ );
730
+ }
731
+ const column = byId.get(columnId);
732
+ if (column === void 0) {
733
+ return () => false;
734
+ }
735
+ return (row) => test(accessDotted(row, column.field), column.type);
736
+ }
737
+ function compileFilterEntry(entry, byId, columns) {
738
+ switch (entry.kind) {
739
+ case "group": {
740
+ const tests = entry.entries.filter((nested) => isEntryUsable(nested, byId)).map((nested) => compileFilterEntry(nested, byId, columns));
741
+ return entry.combinator === "and" ? (row) => tests.every((test) => test(row)) : (row) => tests.some((test) => test(row));
742
+ }
743
+ case "predicate": {
744
+ const { columnId, predicate } = entry;
745
+ const column = columnId === void 0 ? void 0 : byId.get(columnId);
746
+ return (row) => predicate(
747
+ column === void 0 ? void 0 : accessDotted(row, column.field),
748
+ row
749
+ );
750
+ }
751
+ case "operator": {
752
+ const column = byId.get(entry.columnId);
753
+ if (column === void 0) {
754
+ return () => false;
755
+ }
756
+ const test = compileOperatorEntry(entry, column.type);
757
+ return (row) => test(accessDotted(row, column.field));
758
+ }
759
+ case "value": {
760
+ const { value } = entry;
761
+ return compileCellTest(
762
+ entry.columnId,
763
+ byId,
764
+ columns,
765
+ (cell, type) => matchesTypedValue(cell, value, type)
766
+ );
767
+ }
768
+ case "text": {
769
+ const test = compileFilterQuery(entry.query);
770
+ return compileCellTest(entry.columnId, byId, columns, test);
771
+ }
772
+ default:
773
+ return unknownFilterEntry(entry);
774
+ }
775
+ }
776
+ function compileFilter(filter, columns) {
777
+ const byId = new Map(columns.map((entry) => [entry.id, entry.column]));
778
+ const compiled = filter.filter((entry) => isEntryUsable(entry, byId)).map((entry) => compileFilterEntry(entry, byId, columns));
779
+ return compiled.length === 0 ? void 0 : (row) => compiled.every((test) => test(row));
780
+ }
781
+ function matchesQuery(value, query) {
782
+ return compileFilterQuery(query)(value);
783
+ }
784
+ function filterQueryFor(filter, columnId) {
785
+ const entry = filter.find(
786
+ (candidate) => candidate.kind === "text" && candidate.columnId === columnId
787
+ );
788
+ return entry?.query ?? null;
789
+ }
790
+ function setColumnFilter(filter, columnId, query) {
791
+ const index = filter.findIndex(
792
+ (entry) => entry.kind !== "group" && entry.columnId === columnId
793
+ );
794
+ if (query === "") {
795
+ return index === -1 ? filter : filter.filter((_entry, i) => i !== index);
796
+ }
797
+ const next = columnId === void 0 ? { kind: "text", query } : { kind: "text", columnId, query };
798
+ if (index === -1) {
799
+ return [...filter, next];
800
+ }
801
+ const existing = filter[index];
802
+ if (existing?.kind === "text" && existing.query === query) {
803
+ return filter;
804
+ }
805
+ return filter.map((entry, i) => i === index ? next : entry);
806
+ }
807
+ function clearAllFilters(filter) {
808
+ return filter.length === 0 ? filter : [];
809
+ }
810
+ function filterRows(rows, filter, columns) {
811
+ if (filter.length === 0) {
812
+ return rows;
813
+ }
814
+ const test = compileFilter(filter, columns);
815
+ if (test === void 0) {
816
+ return rows;
817
+ }
818
+ const filtered = rows.filter((row) => test(row.row));
819
+ return renumberRows(filtered);
820
+ }
821
+
653
822
  // src/util/serialize.ts
654
823
  function serializeScalar(scalar) {
655
824
  return scalar instanceof Date ? scalar.toISOString() : scalar;
@@ -658,28 +827,32 @@ function serializeOperand(operand) {
658
827
  return isScalarList(operand) ? operand.map(serializeScalar) : serializeScalar(operand);
659
828
  }
660
829
  function serializeEntry(entry) {
661
- if ("combinator" in entry) {
662
- const entries = serializeFilter(entry.entries);
663
- return entries.length === 0 && entry.entries.length > 0 ? void 0 : { combinator: entry.combinator, entries };
664
- }
665
- if ("predicate" in entry) {
666
- reportError(
667
- entry.columnId === void 0 ? "a predicate filter entry across every column cannot be serialised, so it is left out of the saved state." : `a predicate filter entry on \`${entry.columnId}\` cannot be serialised, so it is left out of the saved state.`
668
- );
669
- return void 0;
670
- }
671
- if ("operator" in entry) {
672
- const { value, ...rest } = entry;
673
- return value === void 0 ? rest : { ...rest, value: serializeOperand(value) };
674
- }
675
- if ("value" in entry) {
676
- const { value, ...rest } = entry;
677
- return {
678
- ...rest,
679
- value: value instanceof Date ? value.toISOString() : value
680
- };
830
+ switch (entry.kind) {
831
+ case "group": {
832
+ const entries = serializeFilter(entry.entries);
833
+ return entries.length === 0 && entry.entries.length > 0 ? void 0 : { kind: "group", combinator: entry.combinator, entries };
834
+ }
835
+ case "predicate":
836
+ reportError(
837
+ entry.columnId === void 0 ? "a predicate filter entry across every column cannot be serialised, so it is left out of the saved state." : `a predicate filter entry on \`${entry.columnId}\` cannot be serialised, so it is left out of the saved state.`
838
+ );
839
+ return void 0;
840
+ case "operator": {
841
+ const { value, ...rest } = entry;
842
+ return value === void 0 ? rest : { ...rest, value: serializeOperand(value) };
843
+ }
844
+ case "value": {
845
+ const { value, ...rest } = entry;
846
+ return {
847
+ ...rest,
848
+ value: value instanceof Date ? value.toISOString() : value
849
+ };
850
+ }
851
+ case "text":
852
+ return entry;
853
+ default:
854
+ return unknownFilterEntry(entry);
681
855
  }
682
- return entry;
683
856
  }
684
857
  function serializeFilter(filter) {
685
858
  return filter.map((entry) => serializeEntry(entry)).filter((entry) => entry !== void 0);
@@ -693,25 +866,55 @@ function reviveScalar(scalar, type) {
693
866
  function reviveOperand(operand, type) {
694
867
  return isScalarList(operand) ? operand.map((scalar) => reviveScalar(scalar, type)) : reviveScalar(operand, type);
695
868
  }
696
- function reviveEntry(entry, typeOf) {
869
+ function tagged(entry) {
870
+ if ("kind" in entry) {
871
+ return entry;
872
+ }
697
873
  if ("combinator" in entry) {
698
- return {
699
- combinator: entry.combinator,
700
- entries: reviveEntries(entry.entries, typeOf)
701
- };
874
+ return { ...entry, kind: "group" };
702
875
  }
703
876
  if ("operator" in entry) {
704
- const { value, ...rest } = entry;
705
- return value === void 0 ? rest : { ...rest, value: reviveOperand(value, typeOf(entry.columnId)) };
877
+ return { ...entry, kind: "operator" };
878
+ }
879
+ if ("predicate" in entry) {
880
+ return { ...entry, kind: "predicate" };
706
881
  }
707
882
  if ("value" in entry) {
708
- const { value, ...rest } = entry;
709
- return {
710
- ...rest,
711
- value: typeof value === "string" ? new Date(value) : value
712
- };
883
+ return { ...entry, kind: "value" };
884
+ }
885
+ if ("query" in entry) {
886
+ return { ...entry, kind: "text" };
887
+ }
888
+ throw new TypeError(
889
+ "GridKit: a saved filter entry has no `kind`, nor any key one could be read from."
890
+ );
891
+ }
892
+ function reviveEntry(saved, typeOf) {
893
+ const entry = tagged(saved);
894
+ switch (entry.kind) {
895
+ case "group":
896
+ return {
897
+ kind: "group",
898
+ combinator: entry.combinator,
899
+ entries: reviveEntries(entry.entries, typeOf)
900
+ };
901
+ case "operator": {
902
+ const { value, ...rest } = entry;
903
+ return value === void 0 ? rest : { ...rest, value: reviveOperand(value, typeOf(entry.columnId)) };
904
+ }
905
+ case "value": {
906
+ const { value, ...rest } = entry;
907
+ return {
908
+ ...rest,
909
+ value: typeof value === "string" ? new Date(value) : value
910
+ };
911
+ }
912
+ case "text":
913
+ case "predicate":
914
+ return entry;
915
+ default:
916
+ return unknownFilterEntry(entry);
713
917
  }
714
- return entry;
715
918
  }
716
919
  function reviveEntries(filter, typeOf) {
717
920
  return filter.map((entry) => reviveEntry(entry, typeOf));
@@ -1032,167 +1235,6 @@ function withGroupAggregates(displayRows, flatRows, groupBy, specs, columns, dis
1032
1235
  return renumberRows(out);
1033
1236
  }
1034
1237
 
1035
- // src/util/filtering.ts
1036
- function parseFilterPattern(query) {
1037
- const start = query.startsWith("%");
1038
- const end = query.endsWith("%");
1039
- let text = query;
1040
- if (start) {
1041
- text = text.slice(1);
1042
- }
1043
- if (end) {
1044
- text = text.slice(0, -1);
1045
- }
1046
- text = text.toLowerCase();
1047
- if (start && end) {
1048
- return { mode: "contains", text };
1049
- }
1050
- if (start) {
1051
- return { mode: "endsWith", text };
1052
- }
1053
- if (end) {
1054
- return { mode: "startsWith", text };
1055
- }
1056
- return { mode: "exact", text };
1057
- }
1058
- function isEmptyValue(value) {
1059
- return value === null || value === void 0;
1060
- }
1061
- function compileFilterQuery(query) {
1062
- const { mode, text } = parseFilterPattern(query);
1063
- return (value) => {
1064
- const candidate = (isEmptyValue(value) ? "" : String(value)).toLowerCase();
1065
- switch (mode) {
1066
- case "exact":
1067
- return candidate === text;
1068
- case "contains":
1069
- return candidate.includes(text);
1070
- case "startsWith":
1071
- return candidate.startsWith(text);
1072
- case "endsWith":
1073
- return candidate.endsWith(text);
1074
- }
1075
- };
1076
- }
1077
- function matchesTypedValue(value, target, type) {
1078
- if (typeof target === "number") {
1079
- if (type !== "number" && type !== "decimal" && type !== "currency" && type !== "percent") {
1080
- return false;
1081
- }
1082
- return typeof value === "number" && value === target;
1083
- }
1084
- if (typeof target === "boolean") {
1085
- if (type !== "boolean") {
1086
- return false;
1087
- }
1088
- return typeof value === "boolean" && value === target;
1089
- }
1090
- if (type !== "date" && type !== "dateTime" && type !== "time") {
1091
- return false;
1092
- }
1093
- return value instanceof Date && value.getTime() === target.getTime();
1094
- }
1095
- function isEntryUsable(entry, byId) {
1096
- if ("combinator" in entry) {
1097
- return true;
1098
- }
1099
- return entry.columnId === void 0 || byId.has(entry.columnId);
1100
- }
1101
- function compileFilterEntry(entry, byId, columns) {
1102
- if ("combinator" in entry) {
1103
- const tests = entry.entries.filter((nested) => isEntryUsable(nested, byId)).map((nested) => compileFilterEntry(nested, byId, columns));
1104
- return entry.combinator === "and" ? (row) => tests.every((test2) => test2(row)) : (row) => tests.some((test2) => test2(row));
1105
- }
1106
- if ("predicate" in entry) {
1107
- const { columnId: columnId2, predicate } = entry;
1108
- const column = columnId2 === void 0 ? void 0 : byId.get(columnId2);
1109
- return (row) => predicate(
1110
- column === void 0 ? void 0 : accessDotted(row, column.field),
1111
- row
1112
- );
1113
- }
1114
- if ("operator" in entry) {
1115
- const column = byId.get(entry.columnId);
1116
- if (column === void 0) {
1117
- return () => false;
1118
- }
1119
- const test2 = compileOperatorEntry(entry, column.type);
1120
- return (row) => test2(accessDotted(row, column.field));
1121
- }
1122
- if ("value" in entry) {
1123
- const { columnId: columnId2, value } = entry;
1124
- if (columnId2 !== void 0) {
1125
- const column = byId.get(columnId2);
1126
- if (column === void 0) {
1127
- return () => false;
1128
- }
1129
- return (row) => matchesTypedValue(accessDotted(row, column.field), value, column.type);
1130
- }
1131
- return (row) => columns.some(
1132
- (entry2) => matchesTypedValue(
1133
- accessDotted(row, entry2.column.field),
1134
- value,
1135
- entry2.column.type
1136
- )
1137
- );
1138
- }
1139
- const { columnId, query } = entry;
1140
- const test = compileFilterQuery(query);
1141
- if (columnId !== void 0) {
1142
- const column = byId.get(columnId);
1143
- if (column === void 0) {
1144
- return () => false;
1145
- }
1146
- return (row) => test(accessDotted(row, column.field));
1147
- }
1148
- return (row) => columns.some((entry2) => test(accessDotted(row, entry2.column.field)));
1149
- }
1150
- function compileFilter(filter, columns) {
1151
- const byId = new Map(columns.map((entry) => [entry.id, entry.column]));
1152
- const compiled = filter.filter((entry) => isEntryUsable(entry, byId)).map((entry) => compileFilterEntry(entry, byId, columns));
1153
- return compiled.length === 0 ? void 0 : (row) => compiled.every((test) => test(row));
1154
- }
1155
- function matchesQuery(value, query) {
1156
- return compileFilterQuery(query)(value);
1157
- }
1158
- function filterQueryFor(filter, columnId) {
1159
- const entry = filter.find(
1160
- (candidate) => "query" in candidate && candidate.columnId === columnId
1161
- );
1162
- return entry?.query ?? null;
1163
- }
1164
- function setColumnFilter(filter, columnId, query) {
1165
- const index = filter.findIndex(
1166
- (entry) => !("combinator" in entry) && entry.columnId === columnId
1167
- );
1168
- if (query === "") {
1169
- return index === -1 ? filter : filter.filter((_entry, i) => i !== index);
1170
- }
1171
- const next = columnId === void 0 ? { query } : { columnId, query };
1172
- if (index === -1) {
1173
- return [...filter, next];
1174
- }
1175
- const existing = filter[index];
1176
- if (existing !== void 0 && "query" in existing && existing.query === query) {
1177
- return filter;
1178
- }
1179
- return filter.map((entry, i) => i === index ? next : entry);
1180
- }
1181
- function clearAllFilters(filter) {
1182
- return filter.length === 0 ? filter : [];
1183
- }
1184
- function filterRows(rows, filter, columns) {
1185
- if (filter.length === 0) {
1186
- return rows;
1187
- }
1188
- const test = compileFilter(filter, columns);
1189
- if (test === void 0) {
1190
- return rows;
1191
- }
1192
- const filtered = rows.filter((row) => test(row.row));
1193
- return renumberRows(filtered);
1194
- }
1195
-
1196
1238
  // src/util/rows.ts
1197
1239
  function resolveShownRows(rows, filter, sort, columns) {
1198
1240
  return sortRows(filterRows(rows, filter, columns), sort, columns);
@@ -1405,22 +1447,20 @@ function sameOperand(previous, next) {
1405
1447
  return sameValue(previous, next);
1406
1448
  }
1407
1449
  function sameEntry(previous, next) {
1408
- if ("combinator" in previous || "combinator" in next) {
1409
- return "combinator" in previous && "combinator" in next && previous.combinator === next.combinator && sameFilter(previous.entries, next.entries);
1410
- }
1411
- if (previous.columnId !== next.columnId) {
1412
- return false;
1413
- }
1414
- if ("predicate" in previous || "predicate" in next) {
1415
- return "predicate" in previous && "predicate" in next && previous.predicate === next.predicate;
1416
- }
1417
- if ("operator" in previous || "operator" in next) {
1418
- return "operator" in previous && "operator" in next && previous.operator === next.operator && sameOperand(previous.value, next.value);
1419
- }
1420
- if ("value" in previous || "value" in next) {
1421
- return "value" in previous && "value" in next && sameValue(previous.value, next.value);
1450
+ switch (previous.kind) {
1451
+ case "group":
1452
+ return next.kind === "group" && previous.combinator === next.combinator && sameFilter(previous.entries, next.entries);
1453
+ case "predicate":
1454
+ return next.kind === "predicate" && previous.columnId === next.columnId && previous.predicate === next.predicate;
1455
+ case "operator":
1456
+ return next.kind === "operator" && previous.columnId === next.columnId && previous.operator === next.operator && sameOperand(previous.value, next.value);
1457
+ case "value":
1458
+ return next.kind === "value" && previous.columnId === next.columnId && sameValue(previous.value, next.value);
1459
+ case "text":
1460
+ return next.kind === "text" && previous.columnId === next.columnId && previous.query === next.query;
1461
+ default:
1462
+ return unknownFilterEntry(previous);
1422
1463
  }
1423
- return previous.query === next.query;
1424
1464
  }
1425
1465
  function sameFilter(previous, next) {
1426
1466
  return previous.length === next.length && previous.every((entry, index) => {
@@ -3350,10 +3390,10 @@ function resolveMessages(messages, locale) {
3350
3390
 
3351
3391
  // src/util/filterEditor.ts
3352
3392
  function touchesColumn(entry, columnId) {
3353
- return "combinator" in entry ? entry.entries.some((nested) => touchesColumn(nested, columnId)) : entry.columnId === columnId;
3393
+ return entry.kind === "group" ? entry.entries.some((nested) => touchesColumn(nested, columnId)) : entry.columnId === columnId;
3354
3394
  }
3355
3395
  function isOperatorOn(entry, columnId) {
3356
- return "operator" in entry && entry.columnId === columnId;
3396
+ return entry.kind === "operator" && entry.columnId === columnId;
3357
3397
  }
3358
3398
  function isConditionOn(entry, columnId) {
3359
3399
  return isOperatorOn(entry, columnId) && entry.operator !== "in";
@@ -3365,7 +3405,7 @@ function valuesShape(entry, columnId) {
3365
3405
  if (alone !== void 0) {
3366
3406
  return { kind: "values", values: alone, includeBlanks: false };
3367
3407
  }
3368
- if (!("combinator" in entry) || entry.combinator !== "or" || entry.entries.length !== 2) {
3408
+ if (entry.kind !== "group" || entry.combinator !== "or" || entry.entries.length !== 2) {
3369
3409
  return void 0;
3370
3410
  }
3371
3411
  const [first, second] = entry.entries;
@@ -3374,7 +3414,7 @@ function valuesShape(entry, columnId) {
3374
3414
  }
3375
3415
  function conditionsShape(touching, columnId) {
3376
3416
  const [only] = touching;
3377
- const grouped = touching.length === 1 && only !== void 0 && "combinator" in only;
3417
+ const grouped = touching.length === 1 && only !== void 0 && only.kind === "group";
3378
3418
  const entries = grouped ? only.entries : touching;
3379
3419
  const combinator = grouped ? only.combinator : "and";
3380
3420
  if (entries.length === 0 || entries.length > 2) {
@@ -3569,20 +3609,25 @@ function draftEntries(draft, columnId) {
3569
3609
  ...condition,
3570
3610
  columnId
3571
3611
  }));
3572
- return conditions.length > 1 ? [{ combinator: draft.combinator, entries: conditions }] : conditions;
3612
+ return conditions.length > 1 ? [{ kind: "group", combinator: draft.combinator, entries: conditions }] : conditions;
3573
3613
  }
3574
3614
  if (checksEverything(draft)) {
3575
3615
  return [];
3576
3616
  }
3577
3617
  const picked = {
3618
+ kind: "operator",
3578
3619
  columnId,
3579
3620
  operator: "in",
3580
3621
  value: [...draft.checked.values()]
3581
3622
  };
3582
3623
  return draft.includeBlanks ? [
3583
3624
  {
3625
+ kind: "group",
3584
3626
  combinator: "or",
3585
- entries: [picked, { columnId, operator: "isEmpty" }]
3627
+ entries: [
3628
+ picked,
3629
+ { kind: "operator", columnId, operator: "isEmpty" }
3630
+ ]
3586
3631
  }
3587
3632
  ] : [picked];
3588
3633
  }
@@ -3710,6 +3755,9 @@ function exportCommand({
3710
3755
  isVisible: (context) => isOn(context, EXPORT_AREAS) && resolveExportWriters(context.options.exportWriters).has(format) && (!selection || context.state.rowSelection.length > 0),
3711
3756
  isEnabled: (context) => (selection ? context.selectedRows() : context.view.rows).length > 0,
3712
3757
  execute: (context) => {
3758
+ if (context.host.canSave?.() === false) {
3759
+ return false;
3760
+ }
3713
3761
  const { export: defaults = {}, exportWriters } = context.options;
3714
3762
  const file = exportFile(
3715
3763
  context,
@@ -4633,15 +4681,15 @@ function conditionOf(row, columnId, type) {
4633
4681
  const { operator } = row;
4634
4682
  switch (filterOperandArity(operator)) {
4635
4683
  case 0:
4636
- return { columnId, operator };
4684
+ return { kind: "operator", columnId, operator };
4637
4685
  case 1: {
4638
4686
  const value = parseFilterOperand(row.text, type);
4639
- return value === void 0 ? void 0 : { columnId, operator, value };
4687
+ return value === void 0 ? void 0 : { kind: "operator", columnId, operator, value };
4640
4688
  }
4641
4689
  case 2: {
4642
4690
  const low = parseFilterOperand(row.text, type);
4643
4691
  const high = parseFilterOperand(row.textTo, type);
4644
- return low === void 0 || high === void 0 ? void 0 : { columnId, operator, value: [low, high] };
4692
+ return low === void 0 || high === void 0 ? void 0 : { kind: "operator", columnId, operator, value: [low, high] };
4645
4693
  }
4646
4694
  }
4647
4695
  }