@vectoriox/iox-builder 1.1.1 → 1.1.2

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.
@@ -1263,12 +1263,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
1263
1263
  /**
1264
1264
  * StyleRegistryService — manages a single <style> tag for the builder canvas.
1265
1265
  *
1266
- * Each builder component gets a unique CSS class `.iox-node-{id}` applied to its
1267
- * first inner element. onUpdate() in the style panel calls upsert() to compile
1268
- * the flat style-trait map into a CSS rule and flush it to the stylesheet.
1266
+ * Each builder component gets two CSS classes:
1267
+ * .iox-node-{id} — applied to the inner element; handles layout/visual props
1268
+ * (display, flex, background, border, padding, etc.)
1269
+ * .iox-outer-{id} — applied to the host element by RenderDirective; handles
1270
+ * properties that participate in the PARENT flow (margin,
1271
+ * align-self, flex-grow/shrink/basis, order).
1269
1272
  *
1270
- * This replaces the old [ngStyle] binding, enabling future support for
1271
- * hover states, breakpoints, and pseudo-selectors without DOM modifications.
1273
+ * This split is necessary because margin on an inner wrapper only adds internal
1274
+ * space it does not push sibling elements. Applying margin to the host element
1275
+ * (which IS the flex/block child in the parent container) makes it work correctly.
1272
1276
  *
1273
1277
  * Scoped to PageUiComponent.providers[] — one stylesheet per builder instance.
1274
1278
  */
@@ -1277,6 +1281,11 @@ class StyleRegistryService {
1277
1281
  this.rules = new Map();
1278
1282
  this.styleEl = null;
1279
1283
  }
1284
+ /** Properties that must live on the host element to affect the parent layout. */
1285
+ static { this.OUTER_PROPS = new Set([
1286
+ 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft',
1287
+ 'alignSelf', 'flexGrow', 'flexShrink', 'flexBasis', 'order',
1288
+ ]); }
1280
1289
  init() {
1281
1290
  this.styleEl = document.createElement('style');
1282
1291
  this.styleEl.id = 'iox-runtime-styles';
@@ -1285,9 +1294,21 @@ class StyleRegistryService {
1285
1294
  upsert(nodeId, styles) {
1286
1295
  if (!nodeId)
1287
1296
  return;
1288
- const css = this.compile(nodeId, styles);
1289
- if (css) {
1290
- this.rules.set(nodeId, css);
1297
+ const inner = {};
1298
+ const outer = {};
1299
+ for (const [k, v] of Object.entries(styles)) {
1300
+ if (StyleRegistryService.OUTER_PROPS.has(k)) {
1301
+ outer[k] = v;
1302
+ }
1303
+ else {
1304
+ inner[k] = v;
1305
+ }
1306
+ }
1307
+ const innerCss = this.compile(`iox-node-${nodeId}`, inner);
1308
+ const outerCss = this.compile(`iox-outer-${nodeId}`, outer);
1309
+ const combined = [innerCss, outerCss].filter(Boolean).join('\n');
1310
+ if (combined) {
1311
+ this.rules.set(nodeId, combined);
1291
1312
  }
1292
1313
  else {
1293
1314
  this.rules.delete(nodeId);
@@ -1307,13 +1328,13 @@ class StyleRegistryService {
1307
1328
  this.styleEl = null;
1308
1329
  }
1309
1330
  }
1310
- compile(nodeId, styles) {
1331
+ compile(className, styles) {
1311
1332
  const entries = Object.entries(styles)
1312
1333
  .filter(([, v]) => v !== undefined && v !== null && v !== '')
1313
1334
  .map(([k, v]) => ` ${this.toKebabCase(k)}: ${v};`);
1314
1335
  if (!entries.length)
1315
1336
  return '';
1316
- return `.iox-node-${nodeId} {\n${entries.join('\n')}\n}`;
1337
+ return `.${className} {\n${entries.join('\n')}\n}`;
1317
1338
  }
1318
1339
  toKebabCase(str) {
1319
1340
  return str.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
@@ -1424,10 +1445,15 @@ class RenderDirective {
1424
1445
  }
1425
1446
  // Use styleId when present (clone nodes share the template node's CSS rule).
1426
1447
  const cssId = node.styleId ?? node.id;
1427
- // Register CSS rule in the central stylesheet.
1448
+ // Register CSS rules in the central stylesheet (inner + outer split).
1428
1449
  if (cssId) {
1429
1450
  this.styleRegistry.upsert(cssId, initialStyle);
1430
1451
  }
1452
+ // Apply the outer CSS class to the host element so margin/flex-child
1453
+ // properties affect the parent layout flow, not just internal spacing.
1454
+ if (cssId) {
1455
+ componentRef.location.nativeElement.classList.add(`iox-outer-${cssId}`);
1456
+ }
1431
1457
  // Set nodeId — declared as @Input() on every builder component.
1432
1458
  if (cssId) {
1433
1459
  componentRef.setInput('nodeId', cssId);