@vectoriox/iox-builder 2.3.3 → 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
@@ -2395,6 +2399,39 @@ function arraySchemaFields(properties) {
2395
2399
  }
2396
2400
  return out;
2397
2401
  }
2402
+ /**
2403
+ * Describe the ITEM shape of an array PROPERTY, straight from the schema — the authoritative source
2404
+ * (a resolved sample may be missing, or ambiguous). Given a resource's schema `properties` and the
2405
+ * dot-path to an array field (e.g. `gallery` or `info.items`):
2406
+ * - **object item** → its primitive leaf fields (flattened): `[{label:'url',value:'url'}, …]`.
2407
+ * - **primitive item** (`string[]`/`number[]`) → `isPrimitive:true` (caller offers "(the item value)").
2408
+ * - **can't tell** (many-relation whose items are related docs, or path not found) → both empty, so
2409
+ * the caller falls back to a resolved sample.
2410
+ * JSON-schema arrays store the item schema under `.items`; embedded objects under `.properties`.
2411
+ */
2412
+ function arrayItemSchemaFields(properties, arrayPath) {
2413
+ const parts = (arrayPath ?? '').split('.').filter(Boolean);
2414
+ let field = undefined;
2415
+ let cursor = properties ?? {};
2416
+ for (const part of parts) {
2417
+ field = cursor?.[part];
2418
+ if (!field)
2419
+ return { fields: [], isPrimitive: false };
2420
+ cursor = field.properties ?? field.items?.properties ?? {};
2421
+ }
2422
+ if (!field)
2423
+ return { fields: [], isPrimitive: false };
2424
+ const itemProps = field.items?.properties ?? (field.type === 'embedded' ? field.properties : undefined);
2425
+ if (itemProps && Object.keys(itemProps).length) {
2426
+ return { fields: flattenSchemaFields(itemProps), isPrimitive: false };
2427
+ }
2428
+ // Many-relation: items are related documents — needs the related schema, so let the caller sample.
2429
+ const relType = (field.rel?.type ?? '').toString().toLowerCase();
2430
+ if (field.type === 'rel' || relType.includes('many'))
2431
+ return { fields: [], isPrimitive: false };
2432
+ // Otherwise a primitive-item array (string[]/number[]/…): the item is bound as its own value.
2433
+ return { fields: [], isPrimitive: true };
2434
+ }
2398
2435
 
2399
2436
  /**
2400
2437
  * StyleRegistryService — manages a single <style> tag for the builder canvas.
@@ -5714,8 +5751,14 @@ class BuilderDataSourceService {
5714
5751
  }
5715
5752
  /**
5716
5753
  * Resolve a data source BY ALIAS, following `derived` aliases (a VIEW into another variable:
5717
- * resolve the parent, then getByPath). `findByAlias` is injected so this module stays registry-free
5718
- * (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 → `{}`.
5719
5762
  */
5720
5763
  fetchByAlias(alias, findByAlias) {
5721
5764
  const ds = findByAlias(alias);
@@ -5727,6 +5770,19 @@ class BuilderDataSourceService {
5727
5770
  return of(null);
5728
5771
  return this.fetchByAlias(d.from, findByAlias).pipe(map(parent => getByPath(parent, d.path ?? '')));
5729
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
+ }
5730
5786
  return this.fetch(ds);
5731
5787
  }
5732
5788
  /** Repeater items for an alias (follows derived aliases + applies an optional sourcePath). */
@@ -8143,5 +8199,5 @@ class BuilderSpacerComponentConfig extends ComponentConfig {
8143
8199
  * Generated bundle index. Do not edit.
8144
8200
  */
8145
8201
 
8146
- export { ACTION_TYPE_OPTIONS, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DataSourceType, DeviceMode, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS, EffectsGroupStyleConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, LayoutGroupStyleConfig, ListGroupStyleConfig, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PositionGroupStyleConfig, PresetRegistryService, RELATIONAL_STATES, RELATIONAL_STATE_BASE, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, STRUCTURAL_STATES, SUPPORTED_STATES, SectionComponent, SectionComponentConfig, SizeGroupStyleConfig, SliderContainerComponent, SliderContainerConfig, SliderSlideComponent, SliderSlideConfig, SpacingGroupStyleConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, SymbolRegistryService, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arraySchemaFields, buildFullStyleTraits, buildPresetStyleTraits, defaultPageSettings, flattenSchemaFields, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
8202
+ export { ACTION_TYPE_OPTIONS, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DataSourceType, DeviceMode, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS, EffectsGroupStyleConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, LayoutGroupStyleConfig, ListGroupStyleConfig, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PositionGroupStyleConfig, PresetRegistryService, RELATIONAL_STATES, RELATIONAL_STATE_BASE, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, STRUCTURAL_STATES, SUPPORTED_STATES, SectionComponent, SectionComponentConfig, SizeGroupStyleConfig, SliderContainerComponent, SliderContainerConfig, SliderSlideComponent, SliderSlideConfig, SpacingGroupStyleConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, SymbolRegistryService, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arrayItemSchemaFields, arraySchemaFields, buildFullStyleTraits, buildPresetStyleTraits, defaultPageSettings, flattenSchemaFields, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
8147
8203
  //# sourceMappingURL=vectoriox-iox-builder.mjs.map