@vectoriox/iox-builder 7.0.2 → 8.0.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.
@@ -16,7 +16,7 @@ import { SelectModule } from 'primeng/select';
16
16
  import { TooltipModule } from 'primeng/tooltip';
17
17
  import { DialogModule } from 'primeng/dialog';
18
18
  import * as i1 from '@vectoriox/iox-ui';
19
- import { VALIDATION_STATES as VALIDATION_STATES$1, VALIDATION_STATE_CLASS as VALIDATION_STATE_CLASS$1, DEFAULT_WIDTH_BY_TYPE, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, Breakpoint, BREAKPOINTS, countOverrides, setOverride, defaultElementStyleFor, applyElementStyle, stripSuppressedProps, DeclarationContext, buildPartSelector, planResponsiveRules, resolveStyleProps, buildTargetedStateSelector, statePseudoClass, compileTokenCssBlocks, catalogFontId, fontsForTokens, GOOGLE_FONTS_FILE_ORIGIN, googleFontHref, compileDeclarations, wrapInBreakpointQuery, BreakpointQueryKind, breakpointDef, breakpointForWidth, FormRenderState, safeSetInput, ContextStore, ComponentInstanceRegistryService, isActionEnabled, isContextAction, contextActionEffect, resolveContextValue, declaredInputNames, emptyImagePlaceholder, syncNodeDesignClasses, composeVirtualTraits, withDefaultHoverTransition, stateNamesIn, partClassName, resolveInputs, setInputOverride, collectContextSlotKeys, withContextSlots, compilePageStyle, nodeUsesContext, resolveBoundValue, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, computeRelative, IoxPageModule, PALETTE_PRESETS, elementStyleById, PART_CLASS_NAMES } from '@vectoriox/iox-ui';
19
+ import { VALIDATION_STATES as VALIDATION_STATES$1, VALIDATION_STATE_CLASS as VALIDATION_STATE_CLASS$1, DEFAULT_WIDTH_BY_TYPE, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, Breakpoint, BREAKPOINTS, countOverrides, setOverride, NEW_NODE_STYLE_DEFAULTS, defaultElementStyleFor, applyElementStyle, stripSuppressedProps, DeclarationContext, buildPartSelector, planResponsiveRules, resolveStyleProps, buildTargetedStateSelector, statePseudoClass, compileTokenCssBlocks, catalogFontId, fontsForTokens, GOOGLE_FONTS_FILE_ORIGIN, googleFontHref, compileDeclarations, wrapInBreakpointQuery, BreakpointQueryKind, breakpointDef, breakpointForWidth, FormRenderState, safeSetInput, ContextStore, ComponentInstanceRegistryService, isActionEnabled, isContextAction, contextActionEffect, resolveContextValue, declaredInputNames, emptyImagePlaceholder, syncNodeDesignClasses, composeVirtualTraits, withDefaultHoverTransition, stateNamesIn, partClassName, resolveInputs, setInputOverride, collectContextSlotKeys, withContextSlots, compilePageStyle, nodeUsesContext, resolveBoundValue, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, computeRelative, IoxPageModule, PALETTE_PRESETS, elementStyleById, PART_CLASS_NAMES } from '@vectoriox/iox-ui';
20
20
  export { ComponentInstanceRegistryService, VIRTUAL_TRAIT_KEYS, composeVirtualTraits } from '@vectoriox/iox-ui';
21
21
  import Lenis from 'lenis';
22
22
  import { Subject, BehaviorSubject, of, forkJoin } from 'rxjs';
@@ -1664,16 +1664,33 @@ class ComponentRegistryService {
1664
1664
  }
1665
1665
  /** The unstyled base style map of a NEW node of the type — `switchElementStyle`'s baseline. */
1666
1666
  baselineStyleProps(type) {
1667
+ const out = this.adoptionBaseline(type);
1668
+ for (const [name, value] of Object.entries(NEW_NODE_STYLE_DEFAULTS))
1669
+ if (name in out)
1670
+ out[name] = value;
1671
+ return out;
1672
+ }
1673
+ /** What an untouched SAVED node of the type holds — its constructor defaults, nothing on top.
1674
+ * Adopt (DS7) rewrites an owned trait only while it still holds this. */
1675
+ adoptionBaseline(type) {
1667
1676
  const out = {};
1668
1677
  for (const group of this.createBaseConfig(type)?.styleTraits ?? []) {
1669
1678
  for (const trait of group.traits ?? [])
1670
1679
  out[trait.name] = trait.default;
1671
1680
  }
1672
- for (const [name, value] of Object.entries(NEW_NODE_STYLE_DEFAULTS))
1673
- if (name in out)
1674
- out[name] = value;
1675
1681
  return out;
1676
1682
  }
1683
+ /** The context `adoptElementStyles` (design-core) reads baselines from. */
1684
+ adoptionContext() {
1685
+ const cache = new Map();
1686
+ return {
1687
+ baseline: type => {
1688
+ if (!cache.has(type))
1689
+ cache.set(type, this.adoptionBaseline(type));
1690
+ return cache.get(type);
1691
+ },
1692
+ };
1693
+ }
1677
1694
  register(type, component, config) {
1678
1695
  this.components[type] = { type, component, config };
1679
1696
  }
@@ -1686,13 +1703,6 @@ class ComponentRegistryService {
1686
1703
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.31", ngImport: i0, type: ComponentRegistryService, decorators: [{
1687
1704
  type: Injectable
1688
1705
  }] });
1689
- /**
1690
- * What a new node holds before its element style is written. `color: inherit` because a new node
1691
- * belongs to the section it is dropped into: running text inherits (contract `body`/`lead`), so a
1692
- * literal on any ancestor — a Form, a slide, a field group — would override the section's text.
1693
- * A style that owns a colour (headings, buttons, notices) writes its own over this.
1694
- */
1695
- const NEW_NODE_STYLE_DEFAULTS = { color: 'inherit' };
1696
1706
  /** A new node AND the default children its config builds (a palette Form's fields, submit and
1697
1707
  * notices) are all new elements: each wears its type's default style. */
1698
1708
  function wearDefaultStyles(node) {
@@ -9896,10 +9906,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.31", ngImpo
9896
9906
  }] } });
9897
9907
 
9898
9908
  const MAX_HISTORY = 50;
9909
+ const clone = (value) => (value === undefined ? value : JSON.parse(JSON.stringify(value)));
9899
9910
  /**
9900
9911
  * BuilderHistoryService — snapshot-based undo/redo for the page builder.
9901
9912
  *
9902
- * Snapshots are JSON deep-clones of the full layout array.
9913
+ * Snapshots are JSON deep-clones of the full layout array; a step that also changed state outside
9914
+ * the layout records that change, so one undo reverts both.
9903
9915
  * Session-only — not persisted to the backend.
9904
9916
  * Scoped to PageUiComponent.providers[] — one history stack per builder instance.
9905
9917
  */
@@ -9910,8 +9922,8 @@ class BuilderHistoryService {
9910
9922
  }
9911
9923
  get canUndo() { return this._past.length > 1; }
9912
9924
  get canRedo() { return this._future.length > 0; }
9913
- push(layout) {
9914
- this._past.push({ layout: JSON.parse(JSON.stringify(layout)), timestamp: Date.now() });
9925
+ push(layout, change) {
9926
+ this._past.push({ layout: clone(layout), timestamp: Date.now(), ...(change ? { change: clone(change) } : {}) });
9915
9927
  if (this._past.length > MAX_HISTORY) {
9916
9928
  this._past.shift();
9917
9929
  }
@@ -9922,19 +9934,22 @@ class BuilderHistoryService {
9922
9934
  return null;
9923
9935
  const current = this._past.pop();
9924
9936
  this._future.unshift(current);
9925
- return JSON.parse(JSON.stringify(this._past[this._past.length - 1].layout));
9937
+ return this.step(this._past[this._past.length - 1].layout, current.change?.before, !!current.change);
9926
9938
  }
9927
9939
  redo() {
9928
9940
  if (!this.canRedo)
9929
9941
  return null;
9930
9942
  const next = this._future.shift();
9931
9943
  this._past.push(next);
9932
- return JSON.parse(JSON.stringify(next.layout));
9944
+ return this.step(next.layout, next.change?.after, !!next.change);
9933
9945
  }
9934
9946
  clear() {
9935
9947
  this._past = [];
9936
9948
  this._future = [];
9937
9949
  }
9950
+ step(layout, restore, changed) {
9951
+ return changed ? { layout: clone(layout), restore: clone(restore) } : { layout: clone(layout) };
9952
+ }
9938
9953
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.31", ngImport: i0, type: BuilderHistoryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
9939
9954
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.31", ngImport: i0, type: BuilderHistoryService }); }
9940
9955
  }