@vectoriox/iox-builder 1.3.0 → 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
@@ -4800,5 +4857,5 @@ class TextBlockComponentConfig extends ComponentConfig {
4800
4857
  * Generated bundle index. Do not edit.
4801
4858
  */
4802
4859
 
4803
- 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 };
4804
4861
  //# sourceMappingURL=vectoriox-iox-builder.mjs.map