@outbuild-company/schedule-core 1.35.3 → 1.36.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/dist/index.cjs CHANGED
@@ -2306,24 +2306,37 @@ function toLevelWindow(input) {
2306
2306
  return { startLevel, depth: input.depth };
2307
2307
  }
2308
2308
  var INVALID_CRITERION = /* @__PURE__ */ Symbol("invalid-group-criterion");
2309
- function toSecondaryCriterion(input) {
2310
- const secondary = input.secondary;
2311
- if (secondary === void 0 || secondary === null) return null;
2312
- if (typeof secondary !== "object") return INVALID_CRITERION;
2313
- if (typeof secondary.attributeKey !== "string" || secondary.attributeKey.length === 0) {
2309
+ var MAX_NESTED_GROUP_CRITERIA = 3;
2310
+ function toNestedCriterion(input, usedKeys) {
2311
+ if (typeof input !== "object" || input === null) return INVALID_CRITERION;
2312
+ if (typeof input.attributeKey !== "string" || input.attributeKey.length === 0) {
2314
2313
  return INVALID_CRITERION;
2315
2314
  }
2316
- if (secondary.attributeKey === input.attributeKey) return INVALID_CRITERION;
2317
- const window2 = toLevelWindow(secondary);
2315
+ if (usedKeys.has(input.attributeKey)) return INVALID_CRITERION;
2316
+ const window2 = toLevelWindow(input);
2318
2317
  if (window2 === null) return INVALID_CRITERION;
2319
- if (!isValidDirection(secondary.direction)) return INVALID_CRITERION;
2318
+ if (!isValidDirection(input.direction)) return INVALID_CRITERION;
2320
2319
  return {
2321
- attributeKey: secondary.attributeKey,
2320
+ attributeKey: input.attributeKey,
2322
2321
  startLevel: window2.startLevel,
2323
2322
  depth: window2.depth,
2324
- direction: secondary.direction
2323
+ direction: input.direction
2325
2324
  };
2326
2325
  }
2326
+ function toNestedCriteria(input, primaryKey) {
2327
+ const rawNested = input.nested ?? (input.secondary == null ? [] : [input.secondary]);
2328
+ if (!Array.isArray(rawNested)) return INVALID_CRITERION;
2329
+ if (rawNested.length > MAX_NESTED_GROUP_CRITERIA) return INVALID_CRITERION;
2330
+ const usedKeys = /* @__PURE__ */ new Set([primaryKey]);
2331
+ const nested = [];
2332
+ for (const rawCriterion of rawNested) {
2333
+ const criterion = toNestedCriterion(rawCriterion, usedKeys);
2334
+ if (criterion === INVALID_CRITERION) return INVALID_CRITERION;
2335
+ usedKeys.add(criterion.attributeKey);
2336
+ nested.push(criterion);
2337
+ }
2338
+ return nested;
2339
+ }
2327
2340
  function toGroupState(input) {
2328
2341
  if (typeof input.attributeKey !== "string" || input.attributeKey.length === 0) {
2329
2342
  return null;
@@ -2337,8 +2350,8 @@ function toGroupState(input) {
2337
2350
  if (!Array.isArray(input.collapsedIds) || input.collapsedIds.some((id) => typeof id !== "string")) {
2338
2351
  return null;
2339
2352
  }
2340
- const secondary = toSecondaryCriterion(input);
2341
- if (secondary === INVALID_CRITERION) return null;
2353
+ const nested = toNestedCriteria(input, input.attributeKey);
2354
+ if (nested === INVALID_CRITERION) return null;
2342
2355
  return {
2343
2356
  attributeKey: input.attributeKey,
2344
2357
  startLevel: window2.startLevel,
@@ -2346,7 +2359,7 @@ function toGroupState(input) {
2346
2359
  direction: input.direction,
2347
2360
  includeWbs: input.includeWbs,
2348
2361
  collapsedIds: new Set(input.collapsedIds),
2349
- secondary
2362
+ nested
2350
2363
  };
2351
2364
  }
2352
2365
  function emptyViewChanges(action) {
@@ -25888,7 +25901,7 @@ function emitActivities(node, context) {
25888
25901
  });
25889
25902
  }
25890
25903
  }
25891
- function emitNode(node, childDirection, allowSecondary, context) {
25904
+ function emitNode(node, childDirection, nextNestedIndex, context) {
25892
25905
  const { group, rows } = context;
25893
25906
  rows.push({
25894
25907
  kind: VISUAL_ROW_KIND.GROUP,
@@ -25900,20 +25913,24 @@ function emitNode(node, childDirection, allowSecondary, context) {
25900
25913
  });
25901
25914
  if (group.collapsedIds.has(node.id)) return;
25902
25915
  for (const child of sortedChildNodes(node, childDirection)) {
25903
- emitNode(child, childDirection, allowSecondary, context);
25916
+ emitNode(child, childDirection, nextNestedIndex, context);
25904
25917
  }
25905
25918
  if (node.activities.length === 0) return;
25906
- const secondary = group.secondary;
25907
- if (allowSecondary && secondary != null && context.secondaryCatalog != null) {
25908
- const secondaryRoot = buildGroupTree(
25919
+ const nestedCriterion = group.nested[nextNestedIndex];
25920
+ const nestedCatalog = context.nestedCatalogs[nextNestedIndex] ?? null;
25921
+ if (nestedCriterion != null && nestedCatalog != null) {
25922
+ const nestedRoot = buildGroupTree(
25909
25923
  node.activities,
25910
- secondary,
25911
- context.secondaryCatalog,
25924
+ nestedCriterion,
25925
+ nestedCatalog,
25912
25926
  createNode(node.id, "", "", null, node.level, 0),
25913
25927
  true
25914
25928
  );
25915
- for (const child of sortedChildNodes(secondaryRoot, secondary.direction)) {
25916
- emitNode(child, secondary.direction, false, context);
25929
+ for (const child of sortedChildNodes(
25930
+ nestedRoot,
25931
+ nestedCriterion.direction
25932
+ )) {
25933
+ emitNode(child, nestedCriterion.direction, nextNestedIndex + 1, context);
25917
25934
  }
25918
25935
  return;
25919
25936
  }
@@ -25956,11 +25973,11 @@ function projectVisualRows(input) {
25956
25973
  comparator: input.comparator,
25957
25974
  orderMode: input.orderMode,
25958
25975
  wbsDepth: input.wbsDepth,
25959
- secondaryCatalog: input.secondaryCatalog,
25976
+ nestedCatalogs: input.nestedCatalogs,
25960
25977
  rows
25961
25978
  };
25962
25979
  for (const child of sortedChildNodes(root, group.direction)) {
25963
- emitNode(child, group.direction, true, context);
25980
+ emitNode(child, group.direction, 0, context);
25964
25981
  }
25965
25982
  return rows;
25966
25983
  }
@@ -26366,7 +26383,9 @@ var ScheduleState = class _ScheduleState {
26366
26383
  if (this._cache.visualRows) return this._cache.visualRows;
26367
26384
  const group = this._viewAttributes.getGroup();
26368
26385
  const catalog = group === null ? null : this._viewAttributes.getCatalog(group.attributeKey);
26369
- const secondaryCatalog = group?.secondary == null ? null : this._viewAttributes.getCatalog(group.secondary.attributeKey);
26386
+ const nestedCatalogs = group === null ? [] : group.nested.map(
26387
+ (criterion) => this._viewAttributes.getCatalog(criterion.attributeKey)
26388
+ );
26370
26389
  const activitiesInVisualOrder = [];
26371
26390
  for (const activityId of this.getVisualOrderIds()) {
26372
26391
  const activity = this.getActivity(activityId);
@@ -26379,7 +26398,7 @@ var ScheduleState = class _ScheduleState {
26379
26398
  hasChildren: (activityId) => this.hasChildren(activityId),
26380
26399
  group,
26381
26400
  catalog,
26382
- secondaryCatalog,
26401
+ nestedCatalogs,
26383
26402
  comparator: this.getOrderComparator(),
26384
26403
  orderMode: this.getOrderMode(),
26385
26404
  wbsDepth: this._viewAttributes.getWbsDepth()