ugcinc-render 1.3.7 → 1.3.8

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.
package/dist/index.js CHANGED
@@ -314,27 +314,39 @@ function TextElement({ segment, scale = 1 }) {
314
314
  if (!radii) return void 0;
315
315
  return `${radii[0] * scale}px ${radii[1] * scale}px ${radii[2] * scale}px ${radii[3] * scale}px`;
316
316
  }, [backgroundBorderRadius, scale]);
317
- const containerStyle = (0, import_react.useMemo)(() => ({
317
+ const positioningContainerStyle = (0, import_react.useMemo)(() => ({
318
318
  position: "absolute",
319
319
  left: x,
320
320
  top: y,
321
321
  width,
322
- height: autoWidth ? "auto" : height,
322
+ height,
323
323
  transform: rotation !== 0 ? `rotate(${rotation}deg)` : void 0,
324
324
  transformOrigin: "center center",
325
325
  display: "flex",
326
326
  flexDirection: "column",
327
+ // Vertical alignment within the container
327
328
  justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
328
- // When autoWidth is enabled, align the inner content using flexbox
329
+ // Horizontal alignment (boxAlign) - only applies when autoWidth is enabled
329
330
  alignItems: autoWidth ? boxAlign === "center" ? "center" : boxAlign === "right" ? "flex-end" : "flex-start" : "stretch"
330
331
  }), [x, y, width, height, rotation, verticalAlign, autoWidth, boxAlign]);
331
- const backgroundStyle = (0, import_react.useMemo)(() => {
332
- if (!backgroundColor) return {};
332
+ const backgroundBoxStyle = (0, import_react.useMemo)(() => {
333
+ const baseStyle = autoWidth ? {
334
+ width: "fit-content",
335
+ maxWidth: "100%"
336
+ } : {
337
+ // When not autoWidth, let the text div handle everything
338
+ display: "flex",
339
+ flexDirection: "column",
340
+ flex: 1,
341
+ minHeight: 0
342
+ };
343
+ if (!backgroundColor) return baseStyle;
333
344
  return {
345
+ ...baseStyle,
334
346
  backgroundColor: hexToRgba(backgroundColor, backgroundOpacity),
335
347
  borderRadius: borderRadiusStyle
336
348
  };
337
- }, [backgroundColor, backgroundOpacity, borderRadiusStyle]);
349
+ }, [autoWidth, backgroundColor, backgroundOpacity, borderRadiusStyle]);
338
350
  const textStyle = (0, import_react.useMemo)(() => ({
339
351
  fontFamily,
340
352
  fontSize,
@@ -342,14 +354,18 @@ function TextElement({ segment, scale = 1 }) {
342
354
  color,
343
355
  lineHeight,
344
356
  letterSpacing,
357
+ // textAlign works for multi-line text within the (possibly auto-width) box
345
358
  textAlign: alignment === "justify" ? "justify" : alignment,
346
359
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
347
360
  whiteSpace: "pre-wrap",
348
361
  wordBreak: "break-word",
349
- // When autoWidth is enabled, shrink to fit content but respect max width
350
- ...autoWidth && {
351
- width: "fit-content",
352
- maxWidth: "100%"
362
+ // When not autoWidth, handle vertical alignment via flex
363
+ ...!autoWidth && {
364
+ display: "flex",
365
+ flexDirection: "column",
366
+ justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
367
+ flex: 1,
368
+ minHeight: 0
353
369
  },
354
370
  // Text stroke using text-shadow for cross-browser support
355
371
  ...strokeWidth > 0 && strokeColor && {
@@ -381,9 +397,10 @@ function TextElement({ segment, scale = 1 }) {
381
397
  paddingLeft,
382
398
  strokeWidth,
383
399
  strokeColor,
384
- autoWidth
400
+ autoWidth,
401
+ verticalAlign
385
402
  ]);
386
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { ...containerStyle, ...backgroundStyle }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: textStyle, children: segment.text }) });
403
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: positioningContainerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: backgroundBoxStyle, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: textStyle, children: segment.text }) }) });
387
404
  }
388
405
 
389
406
  // src/components/ImageElement.tsx
package/dist/index.mjs CHANGED
@@ -253,27 +253,39 @@ function TextElement({ segment, scale = 1 }) {
253
253
  if (!radii) return void 0;
254
254
  return `${radii[0] * scale}px ${radii[1] * scale}px ${radii[2] * scale}px ${radii[3] * scale}px`;
255
255
  }, [backgroundBorderRadius, scale]);
256
- const containerStyle = useMemo(() => ({
256
+ const positioningContainerStyle = useMemo(() => ({
257
257
  position: "absolute",
258
258
  left: x,
259
259
  top: y,
260
260
  width,
261
- height: autoWidth ? "auto" : height,
261
+ height,
262
262
  transform: rotation !== 0 ? `rotate(${rotation}deg)` : void 0,
263
263
  transformOrigin: "center center",
264
264
  display: "flex",
265
265
  flexDirection: "column",
266
+ // Vertical alignment within the container
266
267
  justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
267
- // When autoWidth is enabled, align the inner content using flexbox
268
+ // Horizontal alignment (boxAlign) - only applies when autoWidth is enabled
268
269
  alignItems: autoWidth ? boxAlign === "center" ? "center" : boxAlign === "right" ? "flex-end" : "flex-start" : "stretch"
269
270
  }), [x, y, width, height, rotation, verticalAlign, autoWidth, boxAlign]);
270
- const backgroundStyle = useMemo(() => {
271
- if (!backgroundColor) return {};
271
+ const backgroundBoxStyle = useMemo(() => {
272
+ const baseStyle = autoWidth ? {
273
+ width: "fit-content",
274
+ maxWidth: "100%"
275
+ } : {
276
+ // When not autoWidth, let the text div handle everything
277
+ display: "flex",
278
+ flexDirection: "column",
279
+ flex: 1,
280
+ minHeight: 0
281
+ };
282
+ if (!backgroundColor) return baseStyle;
272
283
  return {
284
+ ...baseStyle,
273
285
  backgroundColor: hexToRgba(backgroundColor, backgroundOpacity),
274
286
  borderRadius: borderRadiusStyle
275
287
  };
276
- }, [backgroundColor, backgroundOpacity, borderRadiusStyle]);
288
+ }, [autoWidth, backgroundColor, backgroundOpacity, borderRadiusStyle]);
277
289
  const textStyle = useMemo(() => ({
278
290
  fontFamily,
279
291
  fontSize,
@@ -281,14 +293,18 @@ function TextElement({ segment, scale = 1 }) {
281
293
  color,
282
294
  lineHeight,
283
295
  letterSpacing,
296
+ // textAlign works for multi-line text within the (possibly auto-width) box
284
297
  textAlign: alignment === "justify" ? "justify" : alignment,
285
298
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
286
299
  whiteSpace: "pre-wrap",
287
300
  wordBreak: "break-word",
288
- // When autoWidth is enabled, shrink to fit content but respect max width
289
- ...autoWidth && {
290
- width: "fit-content",
291
- maxWidth: "100%"
301
+ // When not autoWidth, handle vertical alignment via flex
302
+ ...!autoWidth && {
303
+ display: "flex",
304
+ flexDirection: "column",
305
+ justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
306
+ flex: 1,
307
+ minHeight: 0
292
308
  },
293
309
  // Text stroke using text-shadow for cross-browser support
294
310
  ...strokeWidth > 0 && strokeColor && {
@@ -320,9 +336,10 @@ function TextElement({ segment, scale = 1 }) {
320
336
  paddingLeft,
321
337
  strokeWidth,
322
338
  strokeColor,
323
- autoWidth
339
+ autoWidth,
340
+ verticalAlign
324
341
  ]);
325
- return /* @__PURE__ */ jsx("div", { style: { ...containerStyle, ...backgroundStyle }, children: /* @__PURE__ */ jsx("div", { style: textStyle, children: segment.text }) });
342
+ return /* @__PURE__ */ jsx("div", { style: positioningContainerStyle, children: /* @__PURE__ */ jsx("div", { style: backgroundBoxStyle, children: /* @__PURE__ */ jsx("div", { style: textStyle, children: segment.text }) }) });
326
343
  }
327
344
 
328
345
  // src/components/ImageElement.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc-render",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Unified rendering package for UGC Inc - shared types, components, and compositions for pixel-perfect client/server rendering",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",