@shival99/z-ui 1.2.22 → 1.2.24

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.
@@ -325,7 +325,7 @@ class ZTableFilterComponent {
325
325
  this.zColumn().setFilterValue(value || undefined);
326
326
  }
327
327
  onDateRangeChange(value) {
328
- if (value && value.start && value.end) {
328
+ if (value && (value.start || value.end)) {
329
329
  this.zColumn().setFilterValue(value);
330
330
  return;
331
331
  }
@@ -1029,124 +1029,136 @@ function columnConfigToColumnDef(config) {
1029
1029
  columnDef.cell = bodyContent;
1030
1030
  }
1031
1031
  columnDef.footer = resolveHeaderOrFooter(getFooterContent(config));
1032
- if (sortConfig?.sortFn) {
1032
+ const isLocalFilterMode = !filterConfig?.mode || filterConfig.mode === 'local';
1033
+ const isLocalSortMode = !sortConfig?.mode || sortConfig.mode === 'local';
1034
+ if (isLocalSortMode && sortConfig?.sortFn) {
1033
1035
  columnDef.sortingFn = sortConfig.sortFn;
1034
1036
  }
1035
- if (filterConfig?.filterFn) {
1036
- columnDef.filterFn = filterConfig.filterFn;
1037
- }
1038
- if (filterConfig?.type === 'select') {
1039
- columnDef.filterFn = (row, columnId, filterValue) => {
1040
- if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
1041
- return true;
1042
- }
1043
- const cellValue = row.getValue(columnId);
1044
- if (Array.isArray(filterValue)) {
1045
- return filterValue.includes(cellValue);
1046
- }
1047
- return cellValue === filterValue;
1048
- };
1037
+ if (!isLocalSortMode) {
1038
+ columnDef.sortingFn = () => 0;
1049
1039
  }
1050
- if (filterConfig?.type === 'multi-select' || filterConfig?.type === 'tags') {
1051
- columnDef.filterFn = (row, columnId, filterValue) => {
1052
- if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
1053
- return true;
1054
- }
1055
- const cellValue = row.getValue(columnId);
1056
- if (!Array.isArray(filterValue)) {
1057
- return cellValue === filterValue;
1058
- }
1059
- const filterSet = new Set(filterValue);
1060
- if (Array.isArray(cellValue)) {
1061
- return cellValue.some(cv => filterSet.has(cv));
1062
- }
1063
- return filterSet.has(cellValue);
1064
- };
1040
+ if (isLocalFilterMode && filterConfig?.filterFn) {
1041
+ columnDef.filterFn = filterConfig.filterFn;
1065
1042
  }
1066
- if (filterConfig?.type === 'date') {
1067
- columnDef.filterFn = (row, columnId, filterValue) => {
1068
- if (!filterValue) {
1069
- return true;
1070
- }
1071
- const cellValue = row.getValue(columnId);
1072
- if (!cellValue) {
1073
- return false;
1074
- }
1075
- const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
1076
- const filterDate = filterValue instanceof Date ? filterValue : new Date(filterValue);
1077
- if (isNaN(cellDate.getTime()) || isNaN(filterDate.getTime())) {
1078
- return false;
1079
- }
1080
- return (cellDate.getFullYear() === filterDate.getFullYear() &&
1081
- cellDate.getMonth() === filterDate.getMonth() &&
1082
- cellDate.getDate() === filterDate.getDate());
1083
- };
1043
+ if (!isLocalFilterMode) {
1044
+ columnDef.filterFn = () => true;
1084
1045
  }
1085
- if (filterConfig?.type === 'date-range') {
1086
- columnDef.filterFn = (row, columnId, filterValue) => {
1087
- if (!filterValue || typeof filterValue !== 'object') {
1088
- return true;
1089
- }
1090
- const { start, end } = filterValue;
1091
- if (!start && !end) {
1092
- return true;
1093
- }
1094
- const cellValue = row.getValue(columnId);
1095
- if (!cellValue) {
1096
- return false;
1097
- }
1098
- const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
1099
- if (isNaN(cellDate.getTime())) {
1100
- return false;
1101
- }
1102
- // Normalize cell date to start of day for comparison
1103
- const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
1104
- if (start) {
1105
- const startDate = start instanceof Date ? start : new Date(start);
1106
- if (!isNaN(startDate.getTime())) {
1107
- const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
1108
- if (cellDateOnly < startDateOnly) {
1046
+ if (isLocalFilterMode && !filterConfig?.filterFn && filterConfig?.type) {
1047
+ switch (filterConfig.type) {
1048
+ case 'select':
1049
+ columnDef.filterFn = (row, columnId, filterValue) => {
1050
+ if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
1051
+ return true;
1052
+ }
1053
+ const cellValue = row.getValue(columnId);
1054
+ if (Array.isArray(filterValue)) {
1055
+ return filterValue.includes(cellValue);
1056
+ }
1057
+ return cellValue === filterValue;
1058
+ };
1059
+ break;
1060
+ case 'multi-select':
1061
+ case 'tags':
1062
+ columnDef.filterFn = (row, columnId, filterValue) => {
1063
+ if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
1064
+ return true;
1065
+ }
1066
+ const cellValue = row.getValue(columnId);
1067
+ if (!Array.isArray(filterValue)) {
1068
+ return cellValue === filterValue;
1069
+ }
1070
+ const filterSet = new Set(filterValue);
1071
+ if (Array.isArray(cellValue)) {
1072
+ return cellValue.some(cv => filterSet.has(cv));
1073
+ }
1074
+ return filterSet.has(cellValue);
1075
+ };
1076
+ break;
1077
+ case 'date':
1078
+ columnDef.filterFn = (row, columnId, filterValue) => {
1079
+ if (!filterValue) {
1080
+ return true;
1081
+ }
1082
+ const cellValue = row.getValue(columnId);
1083
+ if (!cellValue) {
1109
1084
  return false;
1110
1085
  }
1111
- }
1112
- }
1113
- if (end) {
1114
- const endDate = end instanceof Date ? end : new Date(end);
1115
- if (!isNaN(endDate.getTime())) {
1116
- const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
1117
- if (cellDateOnly > endDateOnly) {
1086
+ const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
1087
+ const filterDate = filterValue instanceof Date ? filterValue : new Date(filterValue);
1088
+ if (isNaN(cellDate.getTime()) || isNaN(filterDate.getTime())) {
1118
1089
  return false;
1119
1090
  }
1120
- }
1121
- }
1122
- return true;
1123
- };
1124
- }
1125
- if (filterConfig?.type === 'range') {
1126
- columnDef.filterFn = (row, columnId, filterValue) => {
1127
- if (!filterValue || !Array.isArray(filterValue)) {
1128
- return true;
1129
- }
1130
- const [min, max] = filterValue;
1131
- if (min === undefined && max === undefined) {
1132
- return true;
1133
- }
1134
- const cellValue = row.getValue(columnId);
1135
- if (cellValue === null || cellValue === undefined) {
1136
- return false;
1137
- }
1138
- const numValue = typeof cellValue === 'number' ? cellValue : Number(cellValue);
1139
- if (isNaN(numValue)) {
1140
- return false;
1141
- }
1142
- if (min !== undefined && numValue < min) {
1143
- return false;
1144
- }
1145
- if (max !== undefined && numValue > max) {
1146
- return false;
1147
- }
1148
- return true;
1149
- };
1091
+ return (cellDate.getFullYear() === filterDate.getFullYear() &&
1092
+ cellDate.getMonth() === filterDate.getMonth() &&
1093
+ cellDate.getDate() === filterDate.getDate());
1094
+ };
1095
+ break;
1096
+ case 'date-range':
1097
+ columnDef.filterFn = (row, columnId, filterValue) => {
1098
+ if (!filterValue || typeof filterValue !== 'object') {
1099
+ return true;
1100
+ }
1101
+ const { start, end } = filterValue;
1102
+ if (!start && !end) {
1103
+ return true;
1104
+ }
1105
+ const cellValue = row.getValue(columnId);
1106
+ if (!cellValue) {
1107
+ return false;
1108
+ }
1109
+ const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
1110
+ if (isNaN(cellDate.getTime())) {
1111
+ return false;
1112
+ }
1113
+ const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
1114
+ if (start) {
1115
+ const startDate = start instanceof Date ? start : new Date(start);
1116
+ if (!isNaN(startDate.getTime())) {
1117
+ const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
1118
+ if (cellDateOnly < startDateOnly) {
1119
+ return false;
1120
+ }
1121
+ }
1122
+ }
1123
+ if (end) {
1124
+ const endDate = end instanceof Date ? end : new Date(end);
1125
+ if (!isNaN(endDate.getTime())) {
1126
+ const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
1127
+ if (cellDateOnly > endDateOnly) {
1128
+ return false;
1129
+ }
1130
+ }
1131
+ }
1132
+ return true;
1133
+ };
1134
+ break;
1135
+ case 'range':
1136
+ columnDef.filterFn = (row, columnId, filterValue) => {
1137
+ if (!filterValue || !Array.isArray(filterValue)) {
1138
+ return true;
1139
+ }
1140
+ const [min, max] = filterValue;
1141
+ if (min === undefined && max === undefined) {
1142
+ return true;
1143
+ }
1144
+ const cellValue = row.getValue(columnId);
1145
+ if (cellValue === null || cellValue === undefined) {
1146
+ return false;
1147
+ }
1148
+ const numValue = typeof cellValue === 'number' ? cellValue : Number(cellValue);
1149
+ if (isNaN(numValue)) {
1150
+ return false;
1151
+ }
1152
+ if (min !== undefined && numValue < min) {
1153
+ return false;
1154
+ }
1155
+ if (max !== undefined && numValue > max) {
1156
+ return false;
1157
+ }
1158
+ return true;
1159
+ };
1160
+ break;
1161
+ }
1150
1162
  }
1151
1163
  if (config.columns && config.columns.length > 0) {
1152
1164
  columnDef.columns = config.columns.map(subConfig => columnConfigToColumnDef(subConfig));
@@ -2422,6 +2434,23 @@ class ZTableComponent {
2422
2434
  };
2423
2435
  return columns.some(c => checkFilter(c));
2424
2436
  }, ...(ngDevMode ? [{ debugName: "hasFiltering" }] : []));
2437
+ hasLocalFiltering = computed(() => {
2438
+ const columns = this.zConfig().columns ?? [];
2439
+ const checkLocalFilter = (col) => {
2440
+ const filterConfig = typeof col.filter === 'boolean' ? { enabled: col.filter } : col.filter;
2441
+ if (filterConfig?.enabled) {
2442
+ const filterMode = filterConfig.mode ?? 'local';
2443
+ if (filterMode === 'local') {
2444
+ return true;
2445
+ }
2446
+ }
2447
+ if (col.columns?.length) {
2448
+ return col.columns.some(c => checkLocalFilter(c));
2449
+ }
2450
+ return false;
2451
+ };
2452
+ return columns.some(c => checkLocalFilter(c));
2453
+ }, ...(ngDevMode ? [{ debugName: "hasLocalFiltering" }] : []));
2425
2454
  hasSorting = computed(() => {
2426
2455
  const config = this.zConfig();
2427
2456
  if (config.enableColumnSorting === false) {
@@ -2443,6 +2472,65 @@ class ZTableComponent {
2443
2472
  };
2444
2473
  return columns.some(c => checkSorting(c));
2445
2474
  }, ...(ngDevMode ? [{ debugName: "hasSorting" }] : []));
2475
+ hasLocalSorting = computed(() => {
2476
+ const config = this.zConfig();
2477
+ if (config.enableColumnSorting === false) {
2478
+ return false;
2479
+ }
2480
+ const columns = config.columns ?? [];
2481
+ const checkLocalSorting = (col) => {
2482
+ const sortConfig = typeof col.sort === 'boolean' ? { enabled: col.sort } : col.sort;
2483
+ if (sortConfig?.enabled) {
2484
+ const sortMode = sortConfig.mode ?? 'local';
2485
+ if (sortMode === 'local') {
2486
+ return true;
2487
+ }
2488
+ }
2489
+ if (col.columns?.length) {
2490
+ return col.columns.some(c => checkLocalSorting(c));
2491
+ }
2492
+ return false;
2493
+ };
2494
+ return columns.some(c => checkLocalSorting(c));
2495
+ }, ...(ngDevMode ? [{ debugName: "hasLocalSorting" }] : []));
2496
+ hasServerFiltering = computed(() => {
2497
+ const columns = this.zConfig().columns ?? [];
2498
+ const checkServerFilter = (col) => {
2499
+ const filterConfig = typeof col.filter === 'boolean' ? { enabled: col.filter } : col.filter;
2500
+ if (filterConfig?.enabled) {
2501
+ const filterMode = filterConfig.mode ?? 'local';
2502
+ if (filterMode === 'server') {
2503
+ return true;
2504
+ }
2505
+ }
2506
+ if (col.columns?.length) {
2507
+ return col.columns.some(c => checkServerFilter(c));
2508
+ }
2509
+ return false;
2510
+ };
2511
+ return columns.some(c => checkServerFilter(c));
2512
+ }, ...(ngDevMode ? [{ debugName: "hasServerFiltering" }] : []));
2513
+ hasServerSorting = computed(() => {
2514
+ const config = this.zConfig();
2515
+ if (config.enableColumnSorting === false) {
2516
+ return false;
2517
+ }
2518
+ const columns = config.columns ?? [];
2519
+ const checkServerSorting = (col) => {
2520
+ const sortConfig = typeof col.sort === 'boolean' ? { enabled: col.sort } : col.sort;
2521
+ if (sortConfig?.enabled) {
2522
+ const sortMode = sortConfig.mode ?? 'local';
2523
+ if (sortMode === 'server') {
2524
+ return true;
2525
+ }
2526
+ }
2527
+ if (col.columns?.length) {
2528
+ return col.columns.some(c => checkServerSorting(c));
2529
+ }
2530
+ return false;
2531
+ };
2532
+ return columns.some(c => checkServerSorting(c));
2533
+ }, ...(ngDevMode ? [{ debugName: "hasServerSorting" }] : []));
2446
2534
  searchConfig = computed(() => {
2447
2535
  const { search } = this.zConfig();
2448
2536
  if (!search) {
@@ -2766,19 +2854,23 @@ class ZTableComponent {
2766
2854
  const isServerMode = config.mode === 'server';
2767
2855
  const pageSize = this.pagination().pageSize || 10;
2768
2856
  const pageCount = isServerMode && config.totalRows ? Math.ceil(config.totalRows / pageSize) : undefined;
2857
+ const hasAnyLocalFiltering = this.hasLocalFiltering();
2858
+ const hasAnyLocalSorting = this.hasLocalSorting();
2859
+ const shouldEnableLocalFiltering = !isServerMode || hasAnyLocalFiltering;
2860
+ const shouldEnableLocalSorting = !isServerMode || hasAnyLocalSorting;
2769
2861
  return {
2770
2862
  data: this._data(),
2771
2863
  columns: this._columns(),
2772
2864
  getCoreRowModel: getCoreRowModel(),
2773
2865
  getExpandedRowModel: this.hasExpandColumn() ? getExpandedRowModel() : undefined,
2774
- getFilteredRowModel: !isServerMode && this.hasFiltering() ? getFilteredRowModel() : undefined,
2775
- getSortedRowModel: !isServerMode && this.hasSorting() ? getSortedRowModel() : undefined,
2866
+ getFilteredRowModel: shouldEnableLocalFiltering && this.hasFiltering() ? getFilteredRowModel() : undefined,
2867
+ getSortedRowModel: shouldEnableLocalSorting && this.hasSorting() ? getSortedRowModel() : undefined,
2776
2868
  getPaginationRowModel: !isServerMode && config.enablePagination ? getPaginationRowModel() : undefined,
2777
- getFacetedRowModel: !isServerMode && this.hasFiltering() ? getFacetedRowModel() : undefined,
2778
- getFacetedUniqueValues: !isServerMode && this.hasFiltering() ? getFacetedUniqueValues() : undefined,
2779
- getFacetedMinMaxValues: !isServerMode && this.hasFiltering() ? getFacetedMinMaxValues() : undefined,
2780
- manualFiltering: isServerMode,
2781
- manualSorting: isServerMode,
2869
+ getFacetedRowModel: shouldEnableLocalFiltering && this.hasFiltering() ? getFacetedRowModel() : undefined,
2870
+ getFacetedUniqueValues: shouldEnableLocalFiltering && this.hasFiltering() ? getFacetedUniqueValues() : undefined,
2871
+ getFacetedMinMaxValues: shouldEnableLocalFiltering && this.hasFiltering() ? getFacetedMinMaxValues() : undefined,
2872
+ manualFiltering: isServerMode && !hasAnyLocalFiltering,
2873
+ manualSorting: isServerMode && !hasAnyLocalSorting,
2782
2874
  manualPagination: isServerMode,
2783
2875
  pageCount: pageCount,
2784
2876
  columnResizeMode: 'onChange',
@@ -2832,24 +2924,38 @@ class ZTableComponent {
2832
2924
  this._handleRowSelectionWithParents(newState);
2833
2925
  },
2834
2926
  onColumnFiltersChange: updater => {
2835
- const newState = typeof updater === 'function' ? updater(this.columnFilters()) : updater;
2836
- this._runAsyncStateUpdate(() => {
2837
- this.columnFilters.set(newState);
2838
- if (this.zConfig().mode !== 'server') {
2927
+ const oldState = this.columnFilters();
2928
+ const newState = typeof updater === 'function' ? updater(oldState) : updater;
2929
+ const changedColumnIds = this._getChangedFilterColumnIds(oldState, newState);
2930
+ const hasAnyLocalChange = changedColumnIds.some(id => this._isColumnFilterModeLocal(id));
2931
+ const hasAnyServerChange = changedColumnIds.some(id => !this._isColumnFilterModeLocal(id));
2932
+ const serverModeFilters = this._filterServerModeColumnFilters(newState);
2933
+ this.columnFilters.set(newState);
2934
+ if (hasAnyLocalChange) {
2935
+ this._runAsyncStateUpdate(() => {
2839
2936
  this.pagination.update(p => ({ ...p, pageIndex: 1 }));
2840
- }
2841
- this._emitFilterChangeDebounced(newState, this.globalFilter());
2842
- });
2937
+ }, true);
2938
+ }
2939
+ if (hasAnyServerChange) {
2940
+ this.zChange.emit({
2941
+ type: 'filter',
2942
+ data: { filters: serverModeFilters, search: this.globalFilter() },
2943
+ });
2944
+ }
2843
2945
  },
2844
2946
  onGlobalFilterChange: updater => {
2845
2947
  const newState = typeof updater === 'function' ? updater(this.globalFilter()) : updater;
2948
+ const hasLocalFilter = this.hasLocalFiltering();
2949
+ const serverModeFilters = this._filterServerModeColumnFilters(this.columnFilters());
2846
2950
  this._runAsyncStateUpdate(() => {
2847
2951
  this.globalFilter.set(newState);
2848
- if (this.zConfig().mode !== 'server') {
2952
+ if (hasLocalFilter) {
2849
2953
  this.pagination.update(p => ({ ...p, pageIndex: 1 }));
2850
2954
  }
2851
- this._emitFilterChangeDebounced(this.columnFilters(), newState);
2852
- });
2955
+ if (serverModeFilters.length > 0 || this.hasServerFiltering()) {
2956
+ this._emitFilterChangeDebounced(serverModeFilters, newState);
2957
+ }
2958
+ }, hasLocalFilter);
2853
2959
  },
2854
2960
  onPaginationChange: updater => {
2855
2961
  const newState = typeof updater === 'function' ? updater(this._tanstackPagination()) : updater;
@@ -2861,14 +2967,21 @@ class ZTableComponent {
2861
2967
  });
2862
2968
  },
2863
2969
  onSortingChange: updater => {
2864
- const newState = typeof updater === 'function' ? updater(this.sorting()) : updater;
2865
- this._runAsyncStateUpdate(() => {
2866
- this.sorting.set(newState);
2867
- if (this.zConfig().mode !== 'server') {
2970
+ const oldState = this.sorting();
2971
+ const newState = typeof updater === 'function' ? updater(oldState) : updater;
2972
+ const changedColumnIds = this._getChangedSortColumnIds(oldState, newState);
2973
+ const hasAnyLocalChange = changedColumnIds.some(id => this._isColumnSortModeLocal(id));
2974
+ const hasAnyServerChange = changedColumnIds.some(id => !this._isColumnSortModeLocal(id));
2975
+ const serverModeSorting = this._filterServerModeSorting(newState);
2976
+ this.sorting.set(newState);
2977
+ if (hasAnyLocalChange) {
2978
+ this._runAsyncStateUpdate(() => {
2868
2979
  this.pagination.update(p => ({ ...p, pageIndex: 1 }));
2869
- }
2870
- this.zChange.emit({ type: 'sort', data: { sorting: newState } });
2871
- });
2980
+ }, true);
2981
+ }
2982
+ if (hasAnyServerChange) {
2983
+ this.zChange.emit({ type: 'sort', data: { sorting: serverModeSorting } });
2984
+ }
2872
2985
  },
2873
2986
  onRowPinningChange: updater => {
2874
2987
  const newState = typeof updater === 'function' ? updater(this.rowPinning()) : updater;
@@ -3025,8 +3138,10 @@ class ZTableComponent {
3025
3138
  }
3026
3139
  });
3027
3140
  explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting], () => {
3028
- this._checkVerticalScroll();
3029
- this._checkHorizontalScroll();
3141
+ queueMicrotask(() => {
3142
+ this._checkVerticalScroll();
3143
+ this._checkHorizontalScroll();
3144
+ });
3030
3145
  });
3031
3146
  explicitEffect([this.zLoading, this.isProcessing], () => {
3032
3147
  const loading = this.zLoading();
@@ -3135,9 +3250,12 @@ class ZTableComponent {
3135
3250
  data: { selection: finalState },
3136
3251
  });
3137
3252
  }
3138
- _runAsyncStateUpdate(updateFn) {
3253
+ _runAsyncStateUpdate(updateFn, forceLocal = false) {
3139
3254
  const isServerMode = this.zConfig().mode === 'server';
3140
- if (isServerMode) {
3255
+ const hasLocalFiltering = this.hasLocalFiltering();
3256
+ const hasLocalSorting = this.hasLocalSorting();
3257
+ const shouldRunAsync = !isServerMode || forceLocal || hasLocalFiltering || hasLocalSorting;
3258
+ if (!shouldRunAsync) {
3141
3259
  updateFn();
3142
3260
  return;
3143
3261
  }
@@ -3148,14 +3266,6 @@ class ZTableComponent {
3148
3266
  }, this.zConfig().debounceTime ?? Z_DEFAULT_DEBOUNCE_TIME);
3149
3267
  }
3150
3268
  _emitFilterChangeDebounced(filters, search) {
3151
- const isServerMode = this.zConfig().mode === 'server';
3152
- if (isServerMode) {
3153
- this.zChange.emit({
3154
- type: 'filter',
3155
- data: { filters, search },
3156
- });
3157
- return;
3158
- }
3159
3269
  if (this._filterEmitDebounceTimeout) {
3160
3270
  clearTimeout(this._filterEmitDebounceTimeout);
3161
3271
  }
@@ -3303,10 +3413,8 @@ class ZTableComponent {
3303
3413
  pagination: this.pagination(),
3304
3414
  },
3305
3415
  });
3306
- queueMicrotask(() => {
3307
- this._checkVerticalScroll();
3308
- this._checkHorizontalScroll();
3309
- });
3416
+ this._checkVerticalScroll();
3417
+ this._checkHorizontalScroll();
3310
3418
  });
3311
3419
  }
3312
3420
  toggleHeaderFooterShadow() {
@@ -3581,6 +3689,64 @@ class ZTableComponent {
3581
3689
  }
3582
3690
  return true;
3583
3691
  }
3692
+ _getChangedFilterColumnIds(oldState, newState) {
3693
+ const changedIds = [];
3694
+ const oldMap = new Map(oldState.map(f => [f.id, f.value]));
3695
+ const newMap = new Map(newState.map(f => [f.id, f.value]));
3696
+ for (const filter of newState) {
3697
+ const oldValue = oldMap.get(filter.id);
3698
+ if (JSON.stringify(oldValue) !== JSON.stringify(filter.value)) {
3699
+ changedIds.push(filter.id);
3700
+ }
3701
+ }
3702
+ for (const filter of oldState) {
3703
+ if (!newMap.has(filter.id)) {
3704
+ changedIds.push(filter.id);
3705
+ }
3706
+ }
3707
+ return [...new Set(changedIds)];
3708
+ }
3709
+ _getChangedSortColumnIds(oldState, newState) {
3710
+ const changedIds = [];
3711
+ const oldMap = new Map(oldState.map(s => [s.id, s.desc]));
3712
+ const newMap = new Map(newState.map(s => [s.id, s.desc]));
3713
+ for (const sort of newState) {
3714
+ const oldDesc = oldMap.get(sort.id);
3715
+ if (oldDesc !== sort.desc) {
3716
+ changedIds.push(sort.id);
3717
+ }
3718
+ }
3719
+ for (const sort of oldState) {
3720
+ if (!newMap.has(sort.id)) {
3721
+ changedIds.push(sort.id);
3722
+ }
3723
+ }
3724
+ return [...new Set(changedIds)];
3725
+ }
3726
+ _isColumnFilterModeLocal(columnId) {
3727
+ const columnConfig = this._findColumnConfig(columnId);
3728
+ if (!columnConfig) {
3729
+ return true;
3730
+ }
3731
+ const filterConfig = typeof columnConfig.filter === 'boolean' ? { enabled: columnConfig.filter } : columnConfig.filter;
3732
+ const filterMode = filterConfig?.mode ?? 'local';
3733
+ return filterMode === 'local';
3734
+ }
3735
+ _isColumnSortModeLocal(columnId) {
3736
+ const columnConfig = this._findColumnConfig(columnId);
3737
+ if (!columnConfig) {
3738
+ return true;
3739
+ }
3740
+ const sortConfig = typeof columnConfig.sort === 'boolean' ? { enabled: columnConfig.sort } : columnConfig.sort;
3741
+ const sortMode = sortConfig?.mode ?? 'local';
3742
+ return sortMode === 'local';
3743
+ }
3744
+ _filterServerModeColumnFilters(filters) {
3745
+ return filters.filter(filter => !this._isColumnFilterModeLocal(filter.id));
3746
+ }
3747
+ _filterServerModeSorting(sorting) {
3748
+ return sorting.filter(sort => !this._isColumnSortModeLocal(sort.id));
3749
+ }
3584
3750
  _findColumnConfig(columnId) {
3585
3751
  const { columns } = this.zConfig();
3586
3752
  if (columns !== this._lastColumnsRef) {