@vectoriox/iox-builder 2.1.2 → 2.2.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, IoxPageModule } from '@vectoriox/iox-ui';
|
|
20
|
+
import { ComponentInstanceRegistryService, DEFAULT_WIDTH_BY_TYPE, compileDeclarations, composeVirtualTraits, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, 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';
|
|
@@ -2374,6 +2374,24 @@ function flattenSchemaFields(properties, prefix = '') {
|
|
|
2374
2374
|
}
|
|
2375
2375
|
return result;
|
|
2376
2376
|
}
|
|
2377
|
+
/**
|
|
2378
|
+
* The ARRAY (repeatable) properties of a schema — used by the Bindings panel to auto-suggest which
|
|
2379
|
+
* property of a SINGLE resource a Repeater can iterate over (e.g. `product.gallery`). A field is
|
|
2380
|
+
* repeatable when its schema `type` is `embedded`/`array` (an embedded list) or it is a MANY
|
|
2381
|
+
* relation (`rel.type` contains "many", case-insensitive). Top-level only — the repeat target is a
|
|
2382
|
+
* property of the resource, not a deep leaf.
|
|
2383
|
+
*/
|
|
2384
|
+
function arraySchemaFields(properties) {
|
|
2385
|
+
const out = [];
|
|
2386
|
+
for (const [key, field] of Object.entries(properties ?? {})) {
|
|
2387
|
+
const type = (field?.type ?? '').toString().toLowerCase();
|
|
2388
|
+
const relType = (field?.rel?.type ?? '').toString().toLowerCase();
|
|
2389
|
+
if (type === 'embedded' || type === 'array' || (type === 'rel' && relType.includes('many'))) {
|
|
2390
|
+
out.push({ label: key, value: key });
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
return out;
|
|
2394
|
+
}
|
|
2377
2395
|
|
|
2378
2396
|
/**
|
|
2379
2397
|
* StyleRegistryService — manages a single <style> tag for the builder canvas.
|
|
@@ -5660,7 +5678,15 @@ class BuilderDataSourceService {
|
|
|
5660
5678
|
}
|
|
5661
5679
|
/** Same fetch, always as an array — for the canvas components that repeat over the source. */
|
|
5662
5680
|
fetchItems(ds) {
|
|
5663
|
-
return this.
|
|
5681
|
+
return this.fetchRepeaterItems(ds);
|
|
5682
|
+
}
|
|
5683
|
+
/**
|
|
5684
|
+
* Items a Repeater/Slider iterates over. With `sourcePath` it repeats over an array PROPERTY of a
|
|
5685
|
+
* SINGLE-resource source (e.g. `product.gallery`); without it the source itself is the list.
|
|
5686
|
+
* Uses the SHARED `resolveRepeaterItems` so the canvas preview matches the SSR engine.
|
|
5687
|
+
*/
|
|
5688
|
+
fetchRepeaterItems(ds, sourcePath) {
|
|
5689
|
+
return this.fetch(ds).pipe(map(value => resolveRepeaterItems(value, sourcePath)));
|
|
5664
5690
|
}
|
|
5665
5691
|
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 }); }
|
|
5666
5692
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BuilderDataSourceService }); }
|
|
@@ -5725,6 +5751,17 @@ class BuilderRepeaterComponent {
|
|
|
5725
5751
|
this.previewRows = [];
|
|
5726
5752
|
}
|
|
5727
5753
|
}
|
|
5754
|
+
/** Optional array PROPERTY inside a single-resource source to repeat over (e.g. `gallery`). */
|
|
5755
|
+
get sourcePath() { return this._sourcePath; }
|
|
5756
|
+
set sourcePath(value) {
|
|
5757
|
+
const next = value ?? '';
|
|
5758
|
+
if (next === this._sourcePath)
|
|
5759
|
+
return;
|
|
5760
|
+
this._sourcePath = next;
|
|
5761
|
+
if (this._source) {
|
|
5762
|
+
this.fetchData();
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5728
5765
|
get limit() { return this._limit; }
|
|
5729
5766
|
set limit(value) {
|
|
5730
5767
|
if (value === this._limit)
|
|
@@ -5754,6 +5791,7 @@ class BuilderRepeaterComponent {
|
|
|
5754
5791
|
/** Bound reference passed to [ioxDropzonePostDrop] so the directive can call it. */
|
|
5755
5792
|
this.refreshPreviewsBound = () => { setTimeout(() => this.refreshPreviews()); };
|
|
5756
5793
|
this._source = '';
|
|
5794
|
+
this._sourcePath = '';
|
|
5757
5795
|
this._limit = 10;
|
|
5758
5796
|
}
|
|
5759
5797
|
ngOnInit() {
|
|
@@ -5782,7 +5820,9 @@ class BuilderRepeaterComponent {
|
|
|
5782
5820
|
return;
|
|
5783
5821
|
this.isLoading = true;
|
|
5784
5822
|
this.cdr.markForCheck();
|
|
5785
|
-
|
|
5823
|
+
// sourcePath (when set) repeats over an array PROPERTY of a single-resource source
|
|
5824
|
+
// (e.g. product.gallery); otherwise the source itself is the list. Shared decision.
|
|
5825
|
+
this.dataSourceService.fetchRepeaterItems(this.dsRegistry.findByAlias(this._source), this._sourcePath).subscribe(items => {
|
|
5786
5826
|
this.items = items.slice(0, this._limit);
|
|
5787
5827
|
this.refreshPreviews();
|
|
5788
5828
|
this.isLoading = false;
|
|
@@ -5824,7 +5864,7 @@ class BuilderRepeaterComponent {
|
|
|
5824
5864
|
}
|
|
5825
5865
|
}
|
|
5826
5866
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BuilderRepeaterComponent, deps: [{ token: DragEngineService }, { token: OverlayService }, { token: BuilderDataSourceService }, { token: DataSourceRegistryService }, { token: PanelEventService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
5827
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.11", type: BuilderRepeaterComponent, isStandalone: false, selector: "app-builder-repeater", inputs: { children: "children", style: "style", nodeId: "nodeId", dropListId: "dropListId", source: "source", limit: "limit" }, outputs: { childClick: "childClick", childMouseEnter: "childMouseEnter", childMouseLeave: "childMouseLeave" }, ngImport: i0, template: `
|
|
5867
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.11", type: BuilderRepeaterComponent, isStandalone: false, selector: "app-builder-repeater", inputs: { children: "children", style: "style", nodeId: "nodeId", dropListId: "dropListId", source: "source", sourcePath: "sourcePath", limit: "limit" }, outputs: { childClick: "childClick", childMouseEnter: "childMouseEnter", childMouseLeave: "childMouseLeave" }, ngImport: i0, template: `
|
|
5828
5868
|
<ng-template #badgeContent>
|
|
5829
5869
|
<i class="ph-thin ph-repeat"></i>
|
|
5830
5870
|
<span *ngIf="source">{{ source }}</span>
|
|
@@ -5993,6 +6033,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
|
|
|
5993
6033
|
type: Output
|
|
5994
6034
|
}], source: [{
|
|
5995
6035
|
type: Input
|
|
6036
|
+
}], sourcePath: [{
|
|
6037
|
+
type: Input
|
|
5996
6038
|
}], limit: [{
|
|
5997
6039
|
type: Input
|
|
5998
6040
|
}] } });
|
|
@@ -7843,6 +7885,17 @@ class RepeaterComponentConfig extends ComponentConfig {
|
|
|
7843
7885
|
options: [], // populated at runtime from DataSourceRegistryService aliases
|
|
7844
7886
|
default: '',
|
|
7845
7887
|
},
|
|
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
|
+
},
|
|
7846
7899
|
{
|
|
7847
7900
|
name: 'limit',
|
|
7848
7901
|
label: 'Limit',
|