@one-paragon/angular-utilities 2.5.4-beta.6 → 2.5.4-beta.8

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.
@@ -1182,12 +1182,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
1182
1182
  // <div *customGroupRow="'category'; let group">
1183
1183
  // Category: {{group.groupHeaderDisplay}} - {{group.length}} products
1184
1184
  // </div>
1185
+ //
1186
+ // <!-- Custom group row for multiple grouping keys -->
1187
+ // <div *customGroupRow="['category', 'status']; let group">
1188
+ // Multi-key template: {{group.groupHeaderDisplay}} ({{group.length}} items)
1189
+ // </div>
1185
1190
  class CustomGroupRowDirective {
1186
1191
  constructor() {
1187
1192
  this.templateRef = inject(TemplateRef);
1188
1193
  /**
1189
- * Optional grouping key. If provided, this custom row will only apply when data is grouped by this key.
1194
+ * Optional grouping key(s). If provided, this custom row will only apply when data is grouped by this key or keys.
1190
1195
  * If not provided (or null), this custom row will apply to all groupings.
1196
+ * Can be a single Path<T> or an array of Path<T> values.
1191
1197
  */
1192
1198
  this.$customGroupRow = input(null, { alias: 'customGroupRow', transform: (val) => val === '' ? null : val });
1193
1199
  /**
@@ -1201,7 +1207,7 @@ class CustomGroupRowDirective {
1201
1207
  this.$priority = input(0, { alias: 'customGroupRowPriority' });
1202
1208
  this.$inited = signal(false);
1203
1209
  /**
1204
- * Gets the grouping key this directive applies to, or null for all groupings
1210
+ * Gets the grouping key(s) this directive applies to, or null for all groupings
1205
1211
  */
1206
1212
  this.$groupingKey = computed(() => this.$customGroupRow());
1207
1213
  /**
@@ -1223,7 +1229,13 @@ class CustomGroupRowDirective {
1223
1229
  */
1224
1230
  appliesTo(groupingKey) {
1225
1231
  const targetKey = this.$groupingKey();
1226
- return targetKey === null || targetKey === groupingKey;
1232
+ if (targetKey === null) {
1233
+ return true; // Apply to all groupings
1234
+ }
1235
+ if (Array.isArray(targetKey)) {
1236
+ return targetKey.includes(groupingKey);
1237
+ }
1238
+ return targetKey === groupingKey;
1227
1239
  }
1228
1240
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: CustomGroupRowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1229
1241
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.3", type: CustomGroupRowDirective, isStandalone: true, selector: "[customGroupRow]", inputs: { $customGroupRow: { classPropertyName: "$customGroupRow", publicName: "customGroupRow", isSignal: true, isRequired: false, transformFunction: null }, $customGroupRowTableRef: { classPropertyName: "$customGroupRowTableRef", publicName: "customGroupRowTableRef", isSignal: true, isRequired: false, transformFunction: null }, $priority: { classPropertyName: "$priority", publicName: "customGroupRowPriority", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
@@ -4652,7 +4664,7 @@ const getAllGroupHeaderNames = (data) => {
4652
4664
  const a = supportsGroupBy ? Object.groupBy(groups, group => group.key) : groupBy(groups, 'key');
4653
4665
  return Object.entries(a).map(([key, groups]) => ({
4654
4666
  groupKey: key,
4655
- uniqueNameOfHeadersToExpand: groups.map(g => g.uniqueName)
4667
+ headers: groups.map(g => g.uniqueName)
4656
4668
  }));
4657
4669
  };
4658
4670
  const getAllGroupHeaderNamesByKeys = (data, keys) => {
@@ -4660,7 +4672,7 @@ const getAllGroupHeaderNamesByKeys = (data, keys) => {
4660
4672
  const a = supportsGroupBy ? Object.groupBy(groups, group => group.key) : groupBy(groups, 'key');
4661
4673
  return Object.entries(a).map(([key, groups]) => ({
4662
4674
  groupKey: key,
4663
- uniqueNameOfHeadersToExpand: groups.map(g => g.uniqueName)
4675
+ headers: groups.map(g => g.uniqueName)
4664
4676
  }));
4665
4677
  };
4666
4678
  const getGroupHeaders = (data, filterFunc, arr = [], oneLevel = false) => {
@@ -5013,7 +5025,12 @@ class GenericTableComponent {
5013
5025
  const customGroupRows = this.state.$props().customGroupRows || [];
5014
5026
  // Find the best matching custom group row template
5015
5027
  // First, look for exact key matches, then for global templates (null key)
5016
- const exactMatches = customGroupRows.filter(cgr => cgr.appliesTo(groupingKey) && cgr.$groupingKey() === groupingKey);
5028
+ const exactMatches = customGroupRows.filter(cgr => {
5029
+ if (!cgr.appliesTo(groupingKey))
5030
+ return false;
5031
+ const key = cgr.$groupingKey();
5032
+ return key === groupingKey || (Array.isArray(key) && key.includes(groupingKey));
5033
+ });
5017
5034
  const globalMatches = customGroupRows.filter(cgr => cgr.appliesTo(groupingKey) && cgr.$groupingKey() === null);
5018
5035
  // Sort by priority (higher priority first)
5019
5036
  const allMatches = [...exactMatches, ...globalMatches].sort((a, b) => b.$priority() - a.$priority());
@@ -5053,7 +5070,7 @@ class GenericTableComponent {
5053
5070
  setExpanded(key, groupUniqueName, isExpanded) {
5054
5071
  if (!isExpanded && this.state.$expandedPropForKeyIsAll(key)()) {
5055
5072
  const groupHeaders = getAllGroupHeaderNamesByKeys(this.$displayData(), [key]);
5056
- this.state.expandOfGroup(groupHeaders);
5073
+ this.state.expandOfGroup(groupHeaders.map(g => ({ groupKey: g.groupKey, uniqueNameOfHeadersToExpand: g.headers })));
5057
5074
  }
5058
5075
  this.state.updateExpandedGroups({ key, isExpanded, groupUniqueName });
5059
5076
  }
@@ -6531,7 +6548,11 @@ class TableContainerComponent {
6531
6548
  this.$displayData = computed(() => this.$tableBuilder() && this.$filteredSortedAndGrouped()?.displayData);
6532
6549
  this.expandAllGroups = () => {
6533
6550
  const groupHeaders = getAllGroupHeaderNames(this.$displayData());
6534
- this.state.expandOfGroup(groupHeaders);
6551
+ this.state.expandOfGroup(groupHeaders.map(g => ({ groupKey: g.groupKey, uniqueNameOfHeadersToExpand: g.headers })));
6552
+ };
6553
+ this.expandAllOfGroup = (groupKey) => {
6554
+ const groupHeaders = getAllGroupHeaderNamesByKeys(this.$displayData(), [groupKey]);
6555
+ this.state.expandOfGroup(groupHeaders.map(g => ({ groupKey: g.groupKey, uniqueNameOfHeadersToExpand: g.headers })));
6535
6556
  };
6536
6557
  this.collapseAllGroups = () => this.state.collapseAll();
6537
6558
  this.exportToCsv = () => this.exportToCsvService.exportToCsv(this.$data());