@fuentis/phoenix-ui 0.0.9-alpha.626 → 0.0.9-alpha.627

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.
@@ -2013,6 +2013,7 @@ class TableCaptionComponent {
2013
2013
  * - set/order of filter keys changes
2014
2014
  */
2015
2015
  lastSignature = '';
2016
+ lastOptionsSignature = '';
2016
2017
  ngOnChanges(changes) {
2017
2018
  if (!this.tableConfiguration)
2018
2019
  return;
@@ -2030,10 +2031,16 @@ class TableCaptionComponent {
2030
2031
  // Normalize filters (backward compatible) before building form
2031
2032
  const normalizedFilters = this.normalizeFilters(this.filters);
2032
2033
  const signature = this.buildSignature(this.tableConfiguration.key, normalizedFilters);
2034
+ const optionsSig = this.buildOptionsSignature(normalizedFilters);
2033
2035
  if (signature !== this.lastSignature) {
2034
2036
  this.lastSignature = signature;
2037
+ this.lastOptionsSignature = optionsSig;
2035
2038
  this.buildFiltersForm(normalizedFilters);
2036
2039
  }
2040
+ else if (changes['filters'] && optionsSig !== this.lastOptionsSignature) {
2041
+ this.lastOptionsSignature = optionsSig;
2042
+ this.pruneStaleSelections(normalizedFilters);
2043
+ }
2037
2044
  }
2038
2045
  // ---------------------------------------------------------------------------
2039
2046
  // Filters form (performance-focused)
@@ -2105,6 +2112,55 @@ class TableCaptionComponent {
2105
2112
  const keys = (filtersCfg ?? []).map((f) => f.key).join('|');
2106
2113
  return `${tableKey ?? 'table'}::${keys}`;
2107
2114
  }
2115
+ pruneStaleSelections(filtersCfg) {
2116
+ const patch = {};
2117
+ for (const f of filtersCfg) {
2118
+ const t = f.type ?? 'text';
2119
+ if (t === 'text' || t === 'checkbox')
2120
+ continue;
2121
+ const control = this.filtersForm.get(f.key);
2122
+ if (!control)
2123
+ continue;
2124
+ const options = Array.isArray(f.options) ? f.options : [];
2125
+ const ov = f.optionValue ?? 'key';
2126
+ const validValues = new Set(options.map((o) => (o && typeof o === 'object' ? o[ov] : o)));
2127
+ if (t === 'multiselect') {
2128
+ const current = Array.isArray(control.value) ? control.value : [];
2129
+ const pruned = current.filter((v) => validValues.has(v));
2130
+ if (pruned.length !== current.length)
2131
+ patch[f.key] = pruned;
2132
+ }
2133
+ else if (t === 'boolean-multiselect') {
2134
+ const current = Array.isArray(control.value) ? control.value : [];
2135
+ const pruned = current.filter((o) => {
2136
+ const val = o && typeof o === 'object' ? o[ov] : o;
2137
+ return validValues.has(val);
2138
+ });
2139
+ if (pruned.length !== current.length)
2140
+ patch[f.key] = pruned;
2141
+ }
2142
+ else if (t === 'dropdown' || t === 'person-dropdown') {
2143
+ const current = control.value;
2144
+ if (current != null && current !== '' && !validValues.has(current)) {
2145
+ patch[f.key] = null;
2146
+ }
2147
+ }
2148
+ }
2149
+ if (Object.keys(patch).length > 0) {
2150
+ this.filtersForm.patchValue(patch, { emitEvent: true });
2151
+ }
2152
+ }
2153
+ buildOptionsSignature(filtersCfg) {
2154
+ return (filtersCfg ?? [])
2155
+ .map((f) => {
2156
+ const ov = f.optionValue ?? 'key';
2157
+ const opts = (f.options ?? [])
2158
+ .map((o) => (o && typeof o === 'object' ? (o[ov] ?? JSON.stringify(o)) : String(o)))
2159
+ .join(',');
2160
+ return `${f.key}:[${opts}]`;
2161
+ })
2162
+ .join('|');
2163
+ }
2108
2164
  normalizeMultiInitial(selected) {
2109
2165
  if (selected == null)
2110
2166
  return [];