@vectoriox/iox-builder 2.3.4 → 2.4.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.
@@ -17,10 +17,10 @@ import { SelectModule } from 'primeng/select';
17
17
  import { TooltipModule } from 'primeng/tooltip';
18
18
  import { DialogModule } from 'primeng/dialog';
19
19
  import * as i16 from '@vectoriox/iox-ui';
20
- import { ComponentInstanceRegistryService, DEFAULT_WIDTH_BY_TYPE, compileDeclarations, composeVirtualTraits, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, IoxPageModule } from '@vectoriox/iox-ui';
20
+ import { ComponentInstanceRegistryService, DEFAULT_WIDTH_BY_TYPE, compileDeclarations, composeVirtualTraits, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, computeRelative, IoxPageModule } from '@vectoriox/iox-ui';
21
21
  export { ComponentInstanceRegistryService, VIRTUAL_TRAIT_KEYS, composeVirtualTraits } from '@vectoriox/iox-ui';
22
22
  import Lenis from 'lenis';
23
- import { Subject, BehaviorSubject, of } from 'rxjs';
23
+ import { Subject, BehaviorSubject, of, forkJoin } from 'rxjs';
24
24
  import interact from 'interactjs';
25
25
  import Moveable from 'moveable';
26
26
  import Selecto from 'selecto';
@@ -1897,6 +1897,10 @@ var DataSourceType;
1897
1897
  /** A VIEW into another variable: `{ from: <alias>, path }` (e.g. galleryImages = product.gallery).
1898
1898
  * Resolves to the value one (or more) level(s) into a parent variable — page-scoped. */
1899
1899
  DataSourceType["Derived"] = "derived";
1900
+ /** A ROUTE-CONTEXT value derived from the current route item — `$route`/`$current`/`$siblings`/
1901
+ * `$related`. Not fetched: computed by the shared `computeRelative` from other resolved sources.
1902
+ * See relative-data-sources-plan.md. */
1903
+ DataSourceType["Relative"] = "relative";
1900
1904
  })(DataSourceType || (DataSourceType = {}));
1901
1905
  /**
1902
1906
  * Maps each action type to its logical inverse for auto-populating toggle
@@ -5747,8 +5751,14 @@ class BuilderDataSourceService {
5747
5751
  }
5748
5752
  /**
5749
5753
  * Resolve a data source BY ALIAS, following `derived` aliases (a VIEW into another variable:
5750
- * resolve the parent, then getByPath). `findByAlias` is injected so this module stays registry-free
5751
- * (the caller passes its own page-scoped registry). Recurses for chained derived aliases.
5754
+ * resolve the parent, then getByPath) and `relative` aliases (route-context — `$current`/
5755
+ * `$siblings`/`$related`). `findByAlias` is injected so this module stays registry-free (the caller
5756
+ * passes its own page-scoped registry). Recurses for chained aliases.
5757
+ *
5758
+ * The builder is design time: `relative` sources resolve their dependency aliases (subject +
5759
+ * collection) — a single source falls back to its `defaultId`, a list to the whole collection —
5760
+ * then run the SHARED `computeRelative`, so the canvas shows the SAME neighbours the SSR engine
5761
+ * bakes into the live page. `$route` has no live params at design time → `{}`.
5752
5762
  */
5753
5763
  fetchByAlias(alias, findByAlias) {
5754
5764
  const ds = findByAlias(alias);
@@ -5760,6 +5770,19 @@ class BuilderDataSourceService {
5760
5770
  return of(null);
5761
5771
  return this.fetchByAlias(d.from, findByAlias).pipe(map(parent => getByPath(parent, d.path ?? '')));
5762
5772
  }
5773
+ if (ds.type === 'relative') {
5774
+ const spec = ds.request?.relative;
5775
+ if (!spec)
5776
+ return of(null);
5777
+ if (spec.kind === 'route')
5778
+ return of({});
5779
+ const subjectAlias = spec.kind === 'current' ? spec.from : (spec.subjectFrom ?? spec.from);
5780
+ const needsCollection = spec.kind === 'siblings' || spec.kind === 'related';
5781
+ return forkJoin({
5782
+ subject: subjectAlias ? this.fetchByAlias(subjectAlias, findByAlias) : of(undefined),
5783
+ collection: needsCollection && spec.from ? this.fetchByAlias(spec.from, findByAlias) : of(undefined),
5784
+ }).pipe(map(({ subject, collection }) => computeRelative(spec, { subject, collection, routeParams: {} })));
5785
+ }
5763
5786
  return this.fetch(ds);
5764
5787
  }
5765
5788
  /** Repeater items for an alias (follows derived aliases + applies an optional sourcePath). */