@vectoriox/iox-builder 4.4.0 → 4.5.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.
@@ -8970,6 +8970,108 @@ function matchesControlSearch(name, label, term) {
8970
8970
  return name.toLowerCase().includes(needle) || (label ?? '').toLowerCase().includes(needle);
8971
8971
  }
8972
8972
 
8973
+ const GRID = (columns) => ({ display: 'grid', gridTemplateColumns: columns, gap: '24px', width: '100%' });
8974
+ const ONE_COLUMN = { gridTemplateColumns: 'repeat(1, minmax(0, 1fr))' };
8975
+ const LAYOUT_PRESETS = Object.freeze([
8976
+ {
8977
+ id: 'stack', name: 'Stack', icon: 'ph-thin ph-rows',
8978
+ description: 'Vertical flow with even spacing.',
8979
+ container: { display: 'flex', flexDirection: 'column', gap: '24px', width: '100%' },
8980
+ childCount: 2,
8981
+ },
8982
+ {
8983
+ id: 'two-columns', name: 'Two columns', icon: 'ph-thin ph-columns',
8984
+ description: 'Side by side; stacks on a phone.',
8985
+ container: GRID('repeat(2, minmax(0, 1fr))'),
8986
+ containerResponsive: { [Breakpoint.Small]: ONE_COLUMN },
8987
+ childCount: 2,
8988
+ },
8989
+ {
8990
+ id: 'three-columns', name: 'Three columns', icon: 'ph-thin ph-columns',
8991
+ description: 'Three across; two on a tablet, one on a phone.',
8992
+ container: GRID('repeat(3, minmax(0, 1fr))'),
8993
+ containerResponsive: {
8994
+ [Breakpoint.Tablet]: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' },
8995
+ [Breakpoint.Small]: ONE_COLUMN,
8996
+ },
8997
+ childCount: 3,
8998
+ },
8999
+ {
9000
+ id: 'sidebar-main', name: 'Sidebar + main', icon: 'ph-thin ph-layout',
9001
+ description: 'Fixed sidebar beside flexible content; the sidebar drops under it on a tablet.',
9002
+ container: GRID('280px minmax(0, 1fr)'),
9003
+ containerResponsive: { [Breakpoint.Tablet]: ONE_COLUMN },
9004
+ childCount: 2,
9005
+ },
9006
+ {
9007
+ id: 'card-grid', name: 'Card grid', icon: 'ph-thin ph-squares-four',
9008
+ description: 'A grid of cards: three, then two, then one.',
9009
+ container: GRID('repeat(3, minmax(0, 1fr))'),
9010
+ containerResponsive: {
9011
+ [Breakpoint.Tablet]: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' },
9012
+ [Breakpoint.Small]: ONE_COLUMN,
9013
+ },
9014
+ childCount: 6,
9015
+ child: { minHeight: '160px' },
9016
+ },
9017
+ {
9018
+ id: 'split-hero', name: 'Split hero', icon: 'ph-thin ph-square-split-horizontal',
9019
+ description: 'Text beside media; on a phone the media moves above the text.',
9020
+ container: GRID('minmax(0, 1.2fr) minmax(0, 1fr)'),
9021
+ containerResponsive: { [Breakpoint.Small]: ONE_COLUMN },
9022
+ childCount: 2,
9023
+ // On a phone the MEDIA (child 2) leads — CSS order only, the DOM order never changes.
9024
+ childResponsive: [{ [Breakpoint.Small]: { order: '1' } }, { [Breakpoint.Small]: { order: '0' } }],
9025
+ },
9026
+ ]);
9027
+ /** Set a style trait's value on a node built from a component config. */
9028
+ function setStyleTrait(node, name, value) {
9029
+ for (const group of node.styleTraits ?? []) {
9030
+ const trait = group.traits.find(t => t.name === name);
9031
+ if (trait) {
9032
+ trait.default = value;
9033
+ return;
9034
+ }
9035
+ }
9036
+ }
9037
+ function applyResponsive(node, layers) {
9038
+ if (!layers)
9039
+ return;
9040
+ let responsive = node.responsive;
9041
+ for (const [bp, styles] of Object.entries(layers)) {
9042
+ for (const [prop, value] of Object.entries(styles ?? {})) {
9043
+ responsive = setOverride(responsive, bp, prop, value);
9044
+ }
9045
+ }
9046
+ node.responsive = responsive;
9047
+ }
9048
+ /**
9049
+ * Build a preset's node tree. `createNode` makes an empty node of a type (the component registry in
9050
+ * the builder) — passed in so this stays pure and testable.
9051
+ *
9052
+ * @returns the container node, or `null` when the container type can't be created.
9053
+ */
9054
+ function buildLayoutPreset(def, createNode) {
9055
+ const container = createNode('Container');
9056
+ if (!container)
9057
+ return null;
9058
+ for (const [prop, value] of Object.entries(def.container))
9059
+ setStyleTrait(container, prop, value);
9060
+ applyResponsive(container, def.containerResponsive);
9061
+ const children = [];
9062
+ for (let i = 0; i < def.childCount; i++) {
9063
+ const child = createNode('Container');
9064
+ if (!child)
9065
+ continue;
9066
+ for (const [prop, value] of Object.entries(def.child ?? {}))
9067
+ setStyleTrait(child, prop, value);
9068
+ applyResponsive(child, def.childResponsive?.[i]);
9069
+ children.push(child);
9070
+ }
9071
+ container.children = children;
9072
+ return container;
9073
+ }
9074
+
8973
9075
  class BuilderButtonComponentConfig extends ComponentConfig {
8974
9076
  constructor() {
8975
9077
  super('Button', 'app-builder-button', 'ph-thin ph-cursor-click', 'Basic');
@@ -9523,5 +9625,5 @@ class BuilderSpacerComponentConfig extends ComponentConfig {
9523
9625
  * Generated bundle index. Do not edit.
9524
9626
  */
9525
9627
 
9526
- export { ACTION_TYPE_OPTIONS, AuditCode, AuditPanelComponent, AuditSeverity, BREAKPOINT_PRESENTATION, BUILDER_CANVAS_CONTAINER, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BreadcrumbBarComponent, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ChildLayoutGroupStyleConfig, ComponentConfig, ComponentRegistryService, DEFAULT_ESSENTIAL_TRAITS, DRAG_HANDLE_ATTR, DataSourceRegistryService, DataSourceType, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS$1 as EASING_OPTIONS, ESSENTIAL_TRAITS_BY_TYPE, EffectsGroupStyleConfig, GalleryConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, 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, TARGETED_STATES, TARGETED_STATE_BASE, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arrayItemSchemaFields, arraySchemaFields, auditNodes, buildFullStyleTraits, buildPresetStyleTraits, canFluidise, collapseColumnsProps, columnCountOf, defaultPageSettings, dropTargetLabel, essentialTraitsFor, findNodeLocation, findParentOf, flattenSchemaFields, fluidiseProps, generateNodeId, isHiddenAt, matchesControlSearch, nodeAncestorPath, nodeAncestorPathInEither, reorderProps, resolveInsertTarget, resolveTraitControllerType, resolveTraitOptions, stackChildrenProps, summarise, visibilityProps, wrapNode };
9628
+ export { ACTION_TYPE_OPTIONS, AuditCode, AuditPanelComponent, AuditSeverity, BREAKPOINT_PRESENTATION, BUILDER_CANVAS_CONTAINER, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BreadcrumbBarComponent, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ChildLayoutGroupStyleConfig, ComponentConfig, ComponentRegistryService, DEFAULT_ESSENTIAL_TRAITS, DRAG_HANDLE_ATTR, DataSourceRegistryService, DataSourceType, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS$1 as EASING_OPTIONS, ESSENTIAL_TRAITS_BY_TYPE, EffectsGroupStyleConfig, GalleryConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LAYOUT_PRESETS, 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, TARGETED_STATES, TARGETED_STATE_BASE, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arrayItemSchemaFields, arraySchemaFields, auditNodes, buildFullStyleTraits, buildLayoutPreset, buildPresetStyleTraits, canFluidise, collapseColumnsProps, columnCountOf, defaultPageSettings, dropTargetLabel, essentialTraitsFor, findNodeLocation, findParentOf, flattenSchemaFields, fluidiseProps, generateNodeId, isHiddenAt, matchesControlSearch, nodeAncestorPath, nodeAncestorPathInEither, reorderProps, resolveInsertTarget, resolveTraitControllerType, resolveTraitOptions, setStyleTrait, stackChildrenProps, summarise, visibilityProps, wrapNode };
9527
9629
  //# sourceMappingURL=vectoriox-iox-builder.mjs.map