@vectoriox/iox-builder 1.2.9 → 1.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.
@@ -1308,6 +1308,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
1308
1308
  * space — it does not push sibling elements. Applying margin to the host element
1309
1309
  * (which IS the flex/block child in the parent container) makes it work correctly.
1310
1310
  *
1311
+ * State styles (hover/active/focus) are stored under key `${nodeId}:${state}`
1312
+ * and compiled to `.iox-node-{id}:hover { … }` selectors.
1313
+ *
1314
+ * Design token variables are stored under the reserved key `__tokens__` and
1315
+ * compiled to a `:root { … }` block prepended to all other rules.
1316
+ *
1311
1317
  * Scoped to PageUiComponent.providers[] — one stylesheet per builder instance.
1312
1318
  */
1313
1319
  class StyleRegistryService {
@@ -1327,9 +1333,30 @@ class StyleRegistryService {
1327
1333
  this.styleEl.id = 'iox-runtime-styles';
1328
1334
  document.head.appendChild(this.styleEl);
1329
1335
  }
1330
- upsert(nodeId, styles) {
1336
+ /**
1337
+ * Write or update the base styles for a node, or a pseudo-class state override.
1338
+ *
1339
+ * @param nodeId The node's CSS id (used in `.iox-node-{nodeId}`)
1340
+ * @param styles Flat CSS property map (camelCase keys)
1341
+ * @param state Optional pseudo-class state ('hover' | 'active' | 'focus').
1342
+ * When provided, compiles to `.iox-node-{id}:{state} { … }`.
1343
+ * State rules are NOT partitioned into inner/outer.
1344
+ */
1345
+ upsert(nodeId, styles, state) {
1331
1346
  if (!nodeId)
1332
1347
  return;
1348
+ if (state) {
1349
+ const css = this.compile(`iox-node-${nodeId}:${state}`, styles);
1350
+ const key = `${nodeId}:${state}`;
1351
+ if (css) {
1352
+ this.rules.set(key, css);
1353
+ }
1354
+ else {
1355
+ this.rules.delete(key);
1356
+ }
1357
+ this.flush();
1358
+ return;
1359
+ }
1333
1360
  const inner = {};
1334
1361
  const outer = {};
1335
1362
  for (const [k, v] of Object.entries(styles)) {
@@ -1351,10 +1378,34 @@ class StyleRegistryService {
1351
1378
  }
1352
1379
  this.flush();
1353
1380
  }
1381
+ /**
1382
+ * Write the org-level design token variables as a `:root { … }` block.
1383
+ * Token names should be CSS custom property names without the `--` prefix
1384
+ * (e.g., `{ 'iox-primary-color': '#cb9090' }`).
1385
+ * Pass an empty object to clear all tokens.
1386
+ */
1387
+ upsertTokens(tokens) {
1388
+ const entries = Object.entries(tokens)
1389
+ .filter(([, v]) => v !== undefined && v !== null && v !== '')
1390
+ .map(([k, v]) => ` --${k}: ${v};`);
1391
+ if (entries.length) {
1392
+ this.rules.set('__tokens__', `:root {\n${entries.join('\n')}\n}`);
1393
+ }
1394
+ else {
1395
+ this.rules.delete('__tokens__');
1396
+ }
1397
+ this.flush();
1398
+ }
1354
1399
  remove(nodeId) {
1355
1400
  if (!nodeId)
1356
1401
  return;
1402
+ // Remove base rule and all state rules for this node
1357
1403
  this.rules.delete(nodeId);
1404
+ for (const key of this.rules.keys()) {
1405
+ if (key.startsWith(`${nodeId}:`)) {
1406
+ this.rules.delete(key);
1407
+ }
1408
+ }
1358
1409
  this.flush();
1359
1410
  }
1360
1411
  destroy() {
@@ -1378,7 +1429,12 @@ class StyleRegistryService {
1378
1429
  flush() {
1379
1430
  if (!this.styleEl)
1380
1431
  return;
1381
- this.styleEl.textContent = Array.from(this.rules.values()).join('\n');
1432
+ // __tokens__ always first so variables are available to all subsequent rules
1433
+ const tokenBlock = this.rules.get('__tokens__');
1434
+ const rest = Array.from(this.rules.entries())
1435
+ .filter(([k]) => k !== '__tokens__')
1436
+ .map(([, v]) => v);
1437
+ this.styleEl.textContent = [tokenBlock, ...rest].filter(Boolean).join('\n');
1382
1438
  this.changes$.next();
1383
1439
  }
1384
1440
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: StyleRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -3789,6 +3845,7 @@ const ACTION_TYPE_OPTIONS = [
3789
3845
  { value: 'toggleVisibility', label: 'Toggle visibility' },
3790
3846
  ];
3791
3847
  const EASING_OPTIONS = ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out'];
3848
+ const SUPPORTED_STATES = ['hover', 'active', 'focus'];
3792
3849
  /**
3793
3850
  * Build a full StyleTraitGroup[] schema populated with values from a flat
3794
3851
  * styleProps map. Used when editing a preset in the Style panel — the panel
@@ -3826,6 +3883,7 @@ var TraitInputType;
3826
3883
  TraitInputType["Icon"] = "icon";
3827
3884
  TraitInputType["Media"] = "media";
3828
3885
  TraitInputType["FontFamily"] = "fontFamily";
3886
+ TraitInputType["GridTemplate"] = "gridTemplate";
3829
3887
  })(TraitInputType || (TraitInputType = {}));
3830
3888
  function generateNodeId() {
3831
3889
  return Math.random().toString(36).substr(2, 9);
@@ -3888,6 +3946,7 @@ function resolveTraitControllerType(type) {
3888
3946
  case TraitInputType.Icon: return 'icon';
3889
3947
  case TraitInputType.Media: return 'media';
3890
3948
  case TraitInputType.FontFamily: return 'select';
3949
+ case TraitInputType.GridTemplate: return 'gridTemplate';
3891
3950
  default: return 'text';
3892
3951
  }
3893
3952
  }
@@ -3932,13 +3991,20 @@ class PositionGroupStyleConfig extends GroupStyleConfig {
3932
3991
  class LayoutGroupStyleConfig extends GroupStyleConfig {
3933
3992
  constructor() {
3934
3993
  super(StyleCategory.Layout, [
3935
- new TraitConfig('display', 'Display', TraitInputType.Select, ['block', 'inline', 'inline-block', 'flex'], 'block'),
3994
+ new TraitConfig('display', 'Display', TraitInputType.Select, ['block', 'inline', 'inline-block', 'flex', 'grid'], 'block'),
3995
+ // ── Flex-only ─────────────────────────────────────────────────────
3936
3996
  new TraitConfig('flexDirection', 'Direction', TraitInputType.SelectButton, [
3937
3997
  { value: 'row', label: 'Horizontal', icon: 'ph-thin ph-arrow-right' },
3938
3998
  { value: 'row-reverse', label: 'Horizontal Reversed', icon: 'ph-thin ph-arrow-left' },
3939
3999
  { value: 'column', label: 'Vertical', icon: 'ph-thin ph-arrow-down' },
3940
4000
  { value: 'column-reverse', label: 'Vertical Reversed', icon: 'ph-thin ph-arrow-up' },
3941
4001
  ], 'row', false, { trait: 'display', values: 'flex' }),
4002
+ new TraitConfig('flexWrap', 'Flex Wrap', TraitInputType.SelectButton, [
4003
+ { value: 'nowrap', label: 'No Wrap', icon: 'ph-thin ph-minus' },
4004
+ { value: 'wrap', label: 'Wrap', icon: 'ph-thin ph-arrow-elbow-down-right' },
4005
+ { value: 'wrap-reverse', label: 'Wrap Reversed', icon: 'ph-thin ph-arrow-elbow-up-right' },
4006
+ ], 'nowrap', false, { trait: 'display', values: 'flex' }),
4007
+ // ── Shared flex + grid ────────────────────────────────────────────
3942
4008
  new TraitConfig('justifyContent', 'Justify', TraitInputType.SelectButton, [
3943
4009
  { value: 'flex-start', label: 'Start', icon: 'ph-thin ph-align-left' },
3944
4010
  { value: 'center', label: 'Center', icon: 'ph-thin ph-align-center-horizontal' },
@@ -3946,19 +4012,32 @@ class LayoutGroupStyleConfig extends GroupStyleConfig {
3946
4012
  { value: 'space-between', label: 'Space Between', icon: 'ph-thin ph-distribute-horizontal' },
3947
4013
  { value: 'space-around', label: 'Space Around', icon: 'ph-thin ph-dots-three' },
3948
4014
  { value: 'space-evenly', label: 'Space Evenly', icon: 'ph-thin ph-dots-six' },
3949
- ], 'flex-start', false, { trait: 'display', values: 'flex' }),
3950
- new TraitConfig('alignItems', 'Align', TraitInputType.SelectButton, [
4015
+ ], 'flex-start', false, { trait: 'display', values: ['flex', 'grid'] }),
4016
+ new TraitConfig('alignItems', 'Align Items', TraitInputType.SelectButton, [
3951
4017
  { value: 'stretch', label: 'Stretch', icon: 'ph-thin ph-arrows-vertical' },
3952
- { value: 'flex-start', label: 'Start', icon: 'ph-thin ph-align-top' },
4018
+ { value: 'start', label: 'Start', icon: 'ph-thin ph-align-top' },
3953
4019
  { value: 'center', label: 'Center', icon: 'ph-thin ph-align-center-vertical' },
3954
- { value: 'flex-end', label: 'End', icon: 'ph-thin ph-align-bottom' },
3955
- ], 'stretch', false, { trait: 'display', values: 'flex' }),
3956
- new TraitConfig('flexWrap', 'Flex Wrap', TraitInputType.SelectButton, [
3957
- { value: 'nowrap', label: 'No Wrap', icon: 'ph-thin ph-minus' },
3958
- { value: 'wrap', label: 'Wrap', icon: 'ph-thin ph-arrow-elbow-down-right' },
3959
- { value: 'wrap-reverse', label: 'Wrap Reversed', icon: 'ph-thin ph-arrow-elbow-up-right' },
3960
- ], 'nowrap', false, { trait: 'display', values: 'flex' }),
3961
- new TraitConfig('gap', 'Gap', TraitInputType.Scrub, { min: 0, max: 200, step: 1, units: UNITS_FIXED }, '0px', false, { trait: 'display', values: 'flex' }),
4020
+ { value: 'end', label: 'End', icon: 'ph-thin ph-align-bottom' },
4021
+ ], 'stretch', false, { trait: 'display', values: ['flex', 'grid'] }),
4022
+ new TraitConfig('gap', 'Gap', TraitInputType.Scrub, { min: 0, max: 200, step: 1, units: UNITS_FIXED }, '0px', false, { trait: 'display', values: ['flex', 'grid'] }),
4023
+ // ── Grid-only ─────────────────────────────────────────────────────
4024
+ new TraitConfig('gridTemplateColumns', 'Columns', TraitInputType.GridTemplate, undefined, '1fr', false, { trait: 'display', values: 'grid' }),
4025
+ new TraitConfig('gridTemplateRows', 'Rows', TraitInputType.GridTemplate, undefined, 'auto', false, { trait: 'display', values: 'grid' }),
4026
+ new TraitConfig('justifyItems', 'Justify Items', TraitInputType.SelectButton, [
4027
+ { value: 'stretch', label: 'Stretch', icon: 'ph-thin ph-arrows-horizontal' },
4028
+ { value: 'start', label: 'Start', icon: 'ph-thin ph-align-left' },
4029
+ { value: 'center', label: 'Center', icon: 'ph-thin ph-align-center-horizontal' },
4030
+ { value: 'end', label: 'End', icon: 'ph-thin ph-align-right' },
4031
+ ], 'stretch', false, { trait: 'display', values: 'grid' }),
4032
+ new TraitConfig('alignContent', 'Align Content', TraitInputType.SelectButton, [
4033
+ { value: 'start', label: 'Start', icon: 'ph-thin ph-align-top' },
4034
+ { value: 'center', label: 'Center', icon: 'ph-thin ph-align-center-vertical' },
4035
+ { value: 'end', label: 'End', icon: 'ph-thin ph-align-bottom' },
4036
+ { value: 'space-between', label: 'Space Between', icon: 'ph-thin ph-distribute-vertical' },
4037
+ { value: 'space-around', label: 'Space Around', icon: 'ph-thin ph-dots-three' },
4038
+ { value: 'stretch', label: 'Stretch', icon: 'ph-thin ph-arrows-vertical' },
4039
+ ], 'stretch', false, { trait: 'display', values: 'grid' }),
4040
+ // ── Direction (always visible) ────────────────────────────────────
3962
4041
  new TraitConfig('direction', 'Text Direction', TraitInputType.SelectButton, [
3963
4042
  { value: 'ltr', label: 'LTR' },
3964
4043
  { value: 'rtl', label: 'RTL' },
@@ -4778,5 +4857,5 @@ class TextBlockComponentConfig extends ComponentConfig {
4778
4857
  * Generated bundle index. Do not edit.
4779
4858
  */
4780
4859
 
4781
- export { ACTION_TYPE_OPTIONS, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DeviceMode, DragEngineService, EASING_OPTIONS$1 as EASING_OPTIONS, GroupStyleConfig, IOX_CONTENT_SERVICE, IOX_FONT_MANAGER, InteractionEngineService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PresetRegistryService, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, SectionComponent, SectionComponentConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, buildPresetStyleTraits, defaultPageSettings, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
4860
+ export { ACTION_TYPE_OPTIONS, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DeviceMode, DragEngineService, EASING_OPTIONS$1 as EASING_OPTIONS, GroupStyleConfig, IOX_CONTENT_SERVICE, IOX_FONT_MANAGER, InteractionEngineService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PresetRegistryService, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, SUPPORTED_STATES, SectionComponent, SectionComponentConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, buildPresetStyleTraits, defaultPageSettings, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
4782
4861
  //# sourceMappingURL=vectoriox-iox-builder.mjs.map