@contrail/data-grouping 1.0.53-alpha.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2026-06-03
11
+
12
+ ### Added
13
+
14
+ - `DataGroupingProperty.valueFilter` (`{ mode: 'include' | 'exclude'; values: string[] }`): an optional, caller-supplied rule that restricts a multi-select grouping property's frames to the filter-selected values. Applied in `buildChildDataGroups` via the new `applyGroupingValueFilter` after `getDistinctValues` — pruning the fan-out to the included values (or dropping the excluded ones), while preserving the `(empty)` bucket. No-op for separate-frame mode (`groupMultiSelectInSeparateFrame`) and for non-multi-select grouping. Keeps this package decoupled from `@contrail/filters`: the caller translates its filter criteria into the rule. (VIBE-10759)
15
+
16
+ ### Fixed
17
+
18
+ - `(empty)` group membership now uses the same emptiness test as the distinct-value pass (extracted as `isEmptyGroupingValue`). The two previously diverged: items whose grouping value was an empty array or a whitespace-only string were dropped entirely (they created the `(empty)` frame but no item matched into it), and `false`/`0` values double-counted into `(empty)` on top of their own group. Only observable with `displayItemsWithEmptyGroupingValues = true`. (VIBE-10759)
19
+
10
20
  ## [1.0.50] - (initial changelog entry)
11
21
 
12
22
  - Initial changelog. Prior releases did not include a changelog.
@@ -1,6 +1,7 @@
1
1
  import { DataGroup, DataGroupStructure, DataGroupingProperty } from '../interfaces';
2
2
  import { TypePropertySortOrder } from '@contrail/types';
3
3
  export declare class DataGroupGenerator {
4
+ static isEmptyGroupingValue(value: any): boolean;
4
5
  static getDistinctValues(data: any, rootIndex: any, slugIndex?: any, rootAltIndex?: any, slugAltIndex?: any, groupMultiSelectInSeparateFrame?: boolean, sortOptions?: {
5
6
  sortOrder: TypePropertySortOrder;
6
7
  options: any;
@@ -4,6 +4,15 @@ exports.DataGroupGenerator = void 0;
4
4
  const util_1 = require("@contrail/util");
5
5
  const types_1 = require("@contrail/types");
6
6
  class DataGroupGenerator {
7
+ static isEmptyGroupingValue(value) {
8
+ return ((value === undefined ||
9
+ value === null ||
10
+ value === '' ||
11
+ (Array.isArray(value) && value.length === 0) ||
12
+ (typeof value === 'string' && value.trim() === '') ||
13
+ (typeof value === 'number' && isNaN(value))) &&
14
+ value !== false);
15
+ }
7
16
  static getDistinctValues(data, rootIndex, slugIndex = null, rootAltIndex = null, slugAltIndex = null, groupMultiSelectInSeparateFrame = false, sortOptions = { sortOrder: types_1.TypePropertySortOrder.ASCENDING, options: null }, propertyTypeOptions = { isDate: false, isNumber: false }, displayItemsWithEmptyGroupingValues = false, displayOptionFrameWithNoData = false) {
8
17
  const sortOrder = (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortOrder) || types_1.TypePropertySortOrder.ASCENDING;
9
18
  const options = (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.options) || null;
@@ -23,13 +32,7 @@ class DataGroupGenerator {
23
32
  }
24
33
  }
25
34
  let value = key;
26
- const isEmptyValue = (value === undefined ||
27
- value === null ||
28
- value === '' ||
29
- (Array.isArray(value) && value.length === 0) ||
30
- (typeof value === 'string' && value.trim() === '') ||
31
- (typeof value === 'number' && isNaN(value))) &&
32
- value !== false;
35
+ const isEmptyValue = DataGroupGenerator.isEmptyGroupingValue(value);
33
36
  if (isEmptyValue) {
34
37
  if (displayItemsWithEmptyGroupingValues) {
35
38
  hasEmptyValues = true;
@@ -151,7 +154,7 @@ class DataGroupGenerator {
151
154
  const groupData = data.filter((obj) => {
152
155
  const objVal = util_1.ObjectUtil.getBySlugs(obj, rootIndex, slugIndex) || util_1.ObjectUtil.getBySlugs(obj, rootAltIndex, slugAltIndex);
153
156
  if (val === '(empty)') {
154
- return !objVal;
157
+ return DataGroupGenerator.isEmptyGroupingValue(objVal);
155
158
  }
156
159
  if (propertyTypeOptions.isDate) {
157
160
  const objDate = objVal ? new Date(objVal).toISOString().split('T')[0] : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/data-grouping",
3
- "version": "1.0.53-alpha.0",
3
+ "version": "1.1.0",
4
4
  "description": "Utilities and interfaces for grouping data into hierarchial data structures based on properties.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",