ugcinc-render 1.3.7 → 1.3.9

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,20 @@ function TextElement({ segment, scale = 1 }) {
342
354
  color,
343
355
  lineHeight,
344
356
  letterSpacing,
357
+ // Enable font kerning for proper letter pair spacing
358
+ fontKerning: "normal",
359
+ // textAlign works for multi-line text within the (possibly auto-width) box
345
360
  textAlign: alignment === "justify" ? "justify" : alignment,
346
361
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
347
362
  whiteSpace: "pre-wrap",
348
363
  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%"
364
+ // When not autoWidth, handle vertical alignment via flex
365
+ ...!autoWidth && {
366
+ display: "flex",
367
+ flexDirection: "column",
368
+ justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
369
+ flex: 1,
370
+ minHeight: 0
353
371
  },
354
372
  // Text stroke using text-shadow for cross-browser support
355
373
  ...strokeWidth > 0 && strokeColor && {
@@ -381,9 +399,10 @@ function TextElement({ segment, scale = 1 }) {
381
399
  paddingLeft,
382
400
  strokeWidth,
383
401
  strokeColor,
384
- autoWidth
402
+ autoWidth,
403
+ verticalAlign
385
404
  ]);
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 }) });
405
+ 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
406
  }
388
407
 
389
408
  // 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,20 @@ function TextElement({ segment, scale = 1 }) {
281
293
  color,
282
294
  lineHeight,
283
295
  letterSpacing,
296
+ // Enable font kerning for proper letter pair spacing
297
+ fontKerning: "normal",
298
+ // textAlign works for multi-line text within the (possibly auto-width) box
284
299
  textAlign: alignment === "justify" ? "justify" : alignment,
285
300
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
286
301
  whiteSpace: "pre-wrap",
287
302
  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%"
303
+ // When not autoWidth, handle vertical alignment via flex
304
+ ...!autoWidth && {
305
+ display: "flex",
306
+ flexDirection: "column",
307
+ justifyContent: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
308
+ flex: 1,
309
+ minHeight: 0
292
310
  },
293
311
  // Text stroke using text-shadow for cross-browser support
294
312
  ...strokeWidth > 0 && strokeColor && {
@@ -320,9 +338,10 @@ function TextElement({ segment, scale = 1 }) {
320
338
  paddingLeft,
321
339
  strokeWidth,
322
340
  strokeColor,
323
- autoWidth
341
+ autoWidth,
342
+ verticalAlign
324
343
  ]);
325
- return /* @__PURE__ */ jsx("div", { style: { ...containerStyle, ...backgroundStyle }, children: /* @__PURE__ */ jsx("div", { style: textStyle, children: segment.text }) });
344
+ return /* @__PURE__ */ jsx("div", { style: positioningContainerStyle, children: /* @__PURE__ */ jsx("div", { style: backgroundBoxStyle, children: /* @__PURE__ */ jsx("div", { style: textStyle, children: segment.text }) }) });
326
345
  }
327
346
 
328
347
  // 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.9",
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",