ezfw-core 1.0.57 → 1.0.58
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.
|
@@ -36,6 +36,7 @@ let islandIdCounter = 0;
|
|
|
36
36
|
* Main static renderer class
|
|
37
37
|
*/
|
|
38
38
|
export class StaticHtmlRenderer {
|
|
39
|
+
analyzer;
|
|
39
40
|
constructor() {
|
|
40
41
|
this.analyzer = analyzer;
|
|
41
42
|
}
|
|
@@ -126,6 +127,13 @@ export class StaticHtmlRenderer {
|
|
|
126
127
|
if (definition.attr) {
|
|
127
128
|
config.attr = { ...definition.attr, ...(config.attr || {}) };
|
|
128
129
|
}
|
|
130
|
+
// Merge Ez shortcuts from definition (layout, flex, gap, padding, margin, bg)
|
|
131
|
+
const shortcuts = ['layout', 'flex', 'gap', 'bg', 'px', 'py', 'pt', 'pb', 'pl', 'pr', 'mx', 'my', 'mt', 'mb', 'ml', 'mr'];
|
|
132
|
+
for (const key of shortcuts) {
|
|
133
|
+
if (definition[key] !== undefined && config[key] === undefined) {
|
|
134
|
+
config[key] = definition[key];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
129
137
|
// Render the config tree
|
|
130
138
|
return this.renderConfig(config, ctx);
|
|
131
139
|
}
|
|
@@ -238,7 +246,8 @@ export class StaticHtmlRenderer {
|
|
|
238
246
|
if (config.layout === 'hbox') {
|
|
239
247
|
shortcutStyles.display = 'flex';
|
|
240
248
|
shortcutStyles.flexDirection = 'row';
|
|
241
|
-
}
|
|
249
|
+
}
|
|
250
|
+
else if (config.layout === 'vbox') {
|
|
242
251
|
shortcutStyles.display = 'flex';
|
|
243
252
|
shortcutStyles.flexDirection = 'column';
|
|
244
253
|
}
|
|
@@ -248,7 +257,7 @@ export class StaticHtmlRenderer {
|
|
|
248
257
|
}
|
|
249
258
|
// Gap shortcut (in rem)
|
|
250
259
|
if (config.gap !== undefined) {
|
|
251
|
-
shortcutStyles.gap = typeof config.gap === 'number' ? `${config.gap * 0.5}rem` : config.gap;
|
|
260
|
+
shortcutStyles.gap = typeof config.gap === 'number' ? `${config.gap * 0.5}rem` : String(config.gap);
|
|
252
261
|
}
|
|
253
262
|
// Background shortcut
|
|
254
263
|
if (config.bg !== undefined) {
|
|
@@ -256,19 +265,47 @@ export class StaticHtmlRenderer {
|
|
|
256
265
|
}
|
|
257
266
|
// Padding shortcuts (in rem)
|
|
258
267
|
const toRem = (v) => typeof v === 'number' ? `${v * 0.5}rem` : String(v);
|
|
259
|
-
if (config.px !== undefined) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (config.
|
|
264
|
-
|
|
268
|
+
if (config.px !== undefined) {
|
|
269
|
+
shortcutStyles.paddingLeft = toRem(config.px);
|
|
270
|
+
shortcutStyles.paddingRight = toRem(config.px);
|
|
271
|
+
}
|
|
272
|
+
if (config.py !== undefined) {
|
|
273
|
+
shortcutStyles.paddingTop = toRem(config.py);
|
|
274
|
+
shortcutStyles.paddingBottom = toRem(config.py);
|
|
275
|
+
}
|
|
276
|
+
if (config.pt !== undefined) {
|
|
277
|
+
shortcutStyles.paddingTop = toRem(config.pt);
|
|
278
|
+
}
|
|
279
|
+
if (config.pb !== undefined) {
|
|
280
|
+
shortcutStyles.paddingBottom = toRem(config.pb);
|
|
281
|
+
}
|
|
282
|
+
if (config.pl !== undefined) {
|
|
283
|
+
shortcutStyles.paddingLeft = toRem(config.pl);
|
|
284
|
+
}
|
|
285
|
+
if (config.pr !== undefined) {
|
|
286
|
+
shortcutStyles.paddingRight = toRem(config.pr);
|
|
287
|
+
}
|
|
265
288
|
// Margin shortcuts (in rem)
|
|
266
|
-
if (config.mx !== undefined) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (config.
|
|
271
|
-
|
|
289
|
+
if (config.mx !== undefined) {
|
|
290
|
+
shortcutStyles.marginLeft = toRem(config.mx);
|
|
291
|
+
shortcutStyles.marginRight = toRem(config.mx);
|
|
292
|
+
}
|
|
293
|
+
if (config.my !== undefined) {
|
|
294
|
+
shortcutStyles.marginTop = toRem(config.my);
|
|
295
|
+
shortcutStyles.marginBottom = toRem(config.my);
|
|
296
|
+
}
|
|
297
|
+
if (config.mt !== undefined) {
|
|
298
|
+
shortcutStyles.marginTop = toRem(config.mt);
|
|
299
|
+
}
|
|
300
|
+
if (config.mb !== undefined) {
|
|
301
|
+
shortcutStyles.marginBottom = toRem(config.mb);
|
|
302
|
+
}
|
|
303
|
+
if (config.ml !== undefined) {
|
|
304
|
+
shortcutStyles.marginLeft = toRem(config.ml);
|
|
305
|
+
}
|
|
306
|
+
if (config.mr !== undefined) {
|
|
307
|
+
shortcutStyles.marginRight = toRem(config.mr);
|
|
308
|
+
}
|
|
272
309
|
// Merge shortcut styles with explicit styles (explicit wins)
|
|
273
310
|
const mergedStyles = { ...shortcutStyles, ...(config.style || {}) };
|
|
274
311
|
// Handle style
|
|
@@ -323,11 +360,11 @@ export class StaticHtmlRenderer {
|
|
|
323
360
|
if (islands.length === 0)
|
|
324
361
|
return '';
|
|
325
362
|
const islandsJson = JSON.stringify(islands);
|
|
326
|
-
return `
|
|
327
|
-
<script type="module">
|
|
328
|
-
import { hydrateIslands } from '/ez/islands/runtime.js';
|
|
329
|
-
window.__EZ_ISLANDS__ = ${islandsJson};
|
|
330
|
-
hydrateIslands(window.__EZ_ISLANDS__);
|
|
363
|
+
return `
|
|
364
|
+
<script type="module">
|
|
365
|
+
import { hydrateIslands } from '/ez/islands/runtime.js';
|
|
366
|
+
window.__EZ_ISLANDS__ = ${islandsJson};
|
|
367
|
+
hydrateIslands(window.__EZ_ISLANDS__);
|
|
331
368
|
</script>`;
|
|
332
369
|
}
|
|
333
370
|
/**
|
|
@@ -211,6 +211,14 @@ export class StaticHtmlRenderer {
|
|
|
211
211
|
config.attr = { ...(definition.attr as Record<string, unknown>), ...(config.attr as Record<string, unknown> || {}) };
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
// Merge Ez shortcuts from definition (layout, flex, gap, padding, margin, bg)
|
|
215
|
+
const shortcuts = ['layout', 'flex', 'gap', 'bg', 'px', 'py', 'pt', 'pb', 'pl', 'pr', 'mx', 'my', 'mt', 'mb', 'ml', 'mr'] as const;
|
|
216
|
+
for (const key of shortcuts) {
|
|
217
|
+
if ((definition as Record<string, unknown>)[key] !== undefined && (config as Record<string, unknown>)[key] === undefined) {
|
|
218
|
+
(config as Record<string, unknown>)[key] = (definition as Record<string, unknown>)[key];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
214
222
|
// Render the config tree
|
|
215
223
|
return this.renderConfig(config, ctx);
|
|
216
224
|
}
|
|
@@ -365,7 +373,7 @@ export class StaticHtmlRenderer {
|
|
|
365
373
|
|
|
366
374
|
// Gap shortcut (in rem)
|
|
367
375
|
if (config.gap !== undefined) {
|
|
368
|
-
shortcutStyles.gap = typeof config.gap === 'number' ? `${config.gap * 0.5}rem` : config.gap;
|
|
376
|
+
shortcutStyles.gap = typeof config.gap === 'number' ? `${config.gap * 0.5}rem` : String(config.gap);
|
|
369
377
|
}
|
|
370
378
|
|
|
371
379
|
// Background shortcut
|
package/islands/analyzer.js
CHANGED