@vectoriox/iox-builder 2.2.1 → 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
|
}
|
|
@@ -5738,6 +5762,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
|
|
|
5738
5762
|
}] } });
|
|
5739
5763
|
|
|
5740
5764
|
class BuilderRepeaterComponent {
|
|
5765
|
+
get children() { return this._children; }
|
|
5766
|
+
/** RenderDirective sets `source` (→ fetchData) BEFORE `children`. With an async source the response
|
|
5767
|
+
* lands after children are set, so previews build fine; but a SYNC source (static, or a fast
|
|
5768
|
+
* cache) resolves before children exist, leaving previewRows empty. Rebuild when children arrive
|
|
5769
|
+
* (or change) so both orderings — and loaded pages with sync sources — render their rows. */
|
|
5770
|
+
set children(value) {
|
|
5771
|
+
this._children = value ?? [];
|
|
5772
|
+
if (this.items.length)
|
|
5773
|
+
this.refreshPreviews();
|
|
5774
|
+
}
|
|
5741
5775
|
get source() { return this._source; }
|
|
5742
5776
|
set source(value) {
|
|
5743
5777
|
if (value === this._source)
|
|
@@ -5778,7 +5812,7 @@ class BuilderRepeaterComponent {
|
|
|
5778
5812
|
this.dsRegistry = dsRegistry;
|
|
5779
5813
|
this.panelEventService = panelEventService;
|
|
5780
5814
|
this.cdr = cdr;
|
|
5781
|
-
this.
|
|
5815
|
+
this._children = [];
|
|
5782
5816
|
this.style = {};
|
|
5783
5817
|
this.nodeId = '';
|
|
5784
5818
|
this.dropListId = '';
|
|
@@ -5820,9 +5854,9 @@ class BuilderRepeaterComponent {
|
|
|
5820
5854
|
return;
|
|
5821
5855
|
this.isLoading = true;
|
|
5822
5856
|
this.cdr.markForCheck();
|
|
5823
|
-
//
|
|
5824
|
-
//
|
|
5825
|
-
this.dataSourceService.
|
|
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 => {
|
|
5826
5860
|
this.items = items.slice(0, this._limit);
|
|
5827
5861
|
this.refreshPreviews();
|
|
5828
5862
|
this.isLoading = false;
|
|
@@ -7885,17 +7919,6 @@ class RepeaterComponentConfig extends ComponentConfig {
|
|
|
7885
7919
|
options: [], // populated at runtime from DataSourceRegistryService aliases
|
|
7886
7920
|
default: '',
|
|
7887
7921
|
},
|
|
7888
|
-
{
|
|
7889
|
-
// Repeat over an ARRAY PROPERTY inside a SINGLE resource (e.g. product → `gallery`).
|
|
7890
|
-
// Empty for list/query sources (the source itself is the array). The Bindings panel
|
|
7891
|
-
// populates the options from the resource schema's array fields when the source is a
|
|
7892
|
-
// single resource. See repeater-nested-array-plan.md.
|
|
7893
|
-
name: 'sourcePath',
|
|
7894
|
-
label: 'Repeat over property',
|
|
7895
|
-
type: TraitInputType.Select,
|
|
7896
|
-
options: [], // populated at runtime from the single source's array schema fields
|
|
7897
|
-
default: '',
|
|
7898
|
-
},
|
|
7899
7922
|
{
|
|
7900
7923
|
name: 'limit',
|
|
7901
7924
|
label: 'Limit',
|