@vectoriox/iox-builder 2.2.2 → 2.3.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,7 +17,7 @@ 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, IoxPageModule } 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';
21
21
  export { ComponentInstanceRegistryService, VIRTUAL_TRAIT_KEYS, composeVirtualTraits } from '@vectoriox/iox-ui';
22
22
  import Lenis from 'lenis';
23
23
  import { Subject, BehaviorSubject, of } from 'rxjs';
@@ -1894,6 +1894,9 @@ var DataSourceType;
1894
1894
  DataSourceType["ExternalApi"] = "external-api";
1895
1895
  DataSourceType["InternalApi"] = "internal-api";
1896
1896
  DataSourceType["Static"] = "static";
1897
+ /** A VIEW into another variable: `{ from: <alias>, path }` (e.g. galleryImages = product.gallery).
1898
+ * Resolves to the value one (or more) level(s) into a parent variable — page-scoped. */
1899
+ DataSourceType["Derived"] = "derived";
1897
1900
  })(DataSourceType || (DataSourceType = {}));
1898
1901
  /**
1899
1902
  * Maps each action type to its logical inverse for auto-populating toggle
@@ -5688,6 +5691,27 @@ class BuilderDataSourceService {
5688
5691
  fetchRepeaterItems(ds, sourcePath) {
5689
5692
  return this.fetch(ds).pipe(map(value => resolveRepeaterItems(value, sourcePath)));
5690
5693
  }
5694
+ /**
5695
+ * Resolve a data source BY ALIAS, following `derived` aliases (a VIEW into another variable:
5696
+ * resolve the parent, then getByPath). `findByAlias` is injected so this module stays registry-free
5697
+ * (the caller passes its own page-scoped registry). Recurses for chained derived aliases.
5698
+ */
5699
+ fetchByAlias(alias, findByAlias) {
5700
+ const ds = findByAlias(alias);
5701
+ if (!ds)
5702
+ return of(null);
5703
+ if (ds.type === 'derived') {
5704
+ const d = ds.request?.derived;
5705
+ if (!d?.from)
5706
+ return of(null);
5707
+ return this.fetchByAlias(d.from, findByAlias).pipe(map(parent => getByPath(parent, d.path ?? '')));
5708
+ }
5709
+ return this.fetch(ds);
5710
+ }
5711
+ /** Repeater items for an alias (follows derived aliases + applies an optional sourcePath). */
5712
+ fetchRepeaterItemsByAlias(alias, findByAlias, sourcePath) {
5713
+ return this.fetchByAlias(alias, findByAlias).pipe(map(value => resolveRepeaterItems(value, sourcePath)));
5714
+ }
5691
5715
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BuilderDataSourceService, deps: [{ token: i1.HttpClient }, { token: IOX_DATA_SOURCE_ENDPOINTS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
5692
5716
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BuilderDataSourceService }); }
5693
5717
  }
@@ -5830,9 +5854,9 @@ class BuilderRepeaterComponent {
5830
5854
  return;
5831
5855
  this.isLoading = true;
5832
5856
  this.cdr.markForCheck();
5833
- // sourcePath (when set) repeats over an array PROPERTY of a single-resource source
5834
- // (e.g. product.gallery); otherwise the source itself is the list. Shared decision.
5835
- this.dataSourceService.fetchRepeaterItems(this.dsRegistry.findByAlias(this._source), this._sourcePath).subscribe(items => {
5857
+ // Resolve BY ALIAS so `derived` sources (e.g. galleryImages = product.gallery) follow their
5858
+ // parent. `sourcePath` (legacy/back-compat) still repeats over an array property inline.
5859
+ this.dataSourceService.fetchRepeaterItemsByAlias(this._source, (a) => this.dsRegistry.findByAlias(a), this._sourcePath).subscribe(items => {
5836
5860
  this.items = items.slice(0, this._limit);
5837
5861
  this.refreshPreviews();
5838
5862
  this.isLoading = false;
@@ -7895,17 +7919,6 @@ class RepeaterComponentConfig extends ComponentConfig {
7895
7919
  options: [], // populated at runtime from DataSourceRegistryService aliases
7896
7920
  default: '',
7897
7921
  },
7898
- {
7899
- // Repeat over an ARRAY PROPERTY inside a SINGLE resource (e.g. product → `gallery`).
7900
- // Empty for list/query sources (the source itself is the array). The Bindings panel
7901
- // populates the options from the resource schema's array fields when the source is a
7902
- // single resource. See repeater-nested-array-plan.md.
7903
- name: 'sourcePath',
7904
- label: 'Repeat over property',
7905
- type: TraitInputType.Select,
7906
- options: [], // populated at runtime from the single source's array schema fields
7907
- default: '',
7908
- },
7909
7922
  {
7910
7923
  name: 'limit',
7911
7924
  label: 'Limit',