@unlayer/react-elements 0.1.8 → 0.1.10

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.d.cts CHANGED
@@ -257,20 +257,69 @@ type ItemProps<TValues> = SemanticProps$1<TValues, React.ReactNode> & {
257
257
  style?: React.CSSProperties;
258
258
  mode?: "web" | "email" | "document";
259
259
  };
260
+ /** fontFamily accepts a ready stack object or a bare family-name string. */
261
+ type FontFamilyInput = {
262
+ label: string;
263
+ value: string;
264
+ } | string;
265
+ /** fontWeight accepts a number, a numeric string, or a CSS keyword. */
266
+ type FontWeightInput = number | `${number}` | "normal" | "bold" | "lighter" | "bolder";
267
+ /** A CSS size: a number (treated as px) or a string ("24px", "50%", "1.5em"). */
268
+ type SizeInput = number | (string & {});
269
+ /** Heading levels (h1–h6). */
270
+ type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
271
+ /** Shared text/style props, agent-friendly (replace the loose `any` flat keys). */
272
+ type TextStyleProps = {
273
+ fontFamily?: FontFamilyInput;
274
+ fontWeight?: FontWeightInput;
275
+ fontSize?: SizeInput;
276
+ lineHeight?: SizeInput;
277
+ /** Letter spacing — a CSS string ("0.5px", "-0.01em") or a number (px). */
278
+ letterSpacing?: SizeInput;
279
+ color?: string;
280
+ };
281
+ /** Image `src` accepts a plain URL string or the value object (loosened sizing). */
282
+ type ImageSrcInput = string | {
283
+ url: string;
284
+ width?: SizeInput;
285
+ height?: number;
286
+ autoWidth?: boolean;
287
+ maxWidth?: SizeInput;
288
+ [key: string]: unknown;
289
+ };
260
290
  /** Button component props */
261
- type ButtonProps = ItemProps<ButtonValues>;
291
+ type ButtonProps = Omit<ItemProps<ButtonValues>, keyof TextStyleProps | "width"> & TextStyleProps & {
292
+ /** Display width — a number/px pins the button; "100%" makes it full-width. */
293
+ width?: SizeInput;
294
+ };
262
295
  /** Heading component props */
263
- type HeadingProps = ItemProps<HeadingValues>;
296
+ type HeadingProps = Omit<ItemProps<HeadingValues>, keyof TextStyleProps | "headingType"> & TextStyleProps & {
297
+ /** Heading level h1–h6. */
298
+ headingType?: HeadingLevel;
299
+ /** Alias for `headingType`. */
300
+ level?: HeadingLevel;
301
+ /** Heading text (or use children). */
302
+ text?: string;
303
+ };
264
304
  /** Divider component props */
265
305
  type DividerProps = ItemProps<DividerValues>;
266
306
  /** HTML component props */
267
307
  type HtmlProps = ItemProps<HtmlValues>;
268
308
  /** Paragraph component props */
269
- type ParagraphProps = ItemProps<ParagraphValues>;
309
+ type ParagraphProps = Omit<ItemProps<ParagraphValues>, keyof TextStyleProps> & TextStyleProps & {
310
+ /** Plain-text content (or use `html` for inline formatting, or children). */
311
+ text?: string;
312
+ };
270
313
  /** Image component props — supports `alt` shorthand for `altText`. */
271
- type ImageProps = ItemProps<ImageValues> & {
314
+ type ImageProps = Omit<ItemProps<ImageValues>, "src" | "width" | "maxWidth"> & {
272
315
  /** Alt text (alias for altText) */
273
316
  alt?: string;
317
+ /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */
318
+ src?: ImageSrcInput;
319
+ /** Display width — number/px pins the image; "50%" sets a percentage width. */
320
+ width?: SizeInput;
321
+ /** Display width as a CSS value ("50%", "300px"). */
322
+ maxWidth?: SizeInput;
274
323
  };
275
324
  /** Social component props — supports `icons` shorthand array. */
276
325
  type SocialProps = ItemProps<SocialValues> & {
@@ -338,6 +387,14 @@ type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & TSemanticProp
338
387
  */
339
388
  type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
340
389
 
390
+ /**
391
+ * Button semantic props — agent-friendly text/style types (replacing the loose
392
+ * `any` flat props) plus a CSS-style `width` (number/px pins; "100%" full-width).
393
+ */
394
+ type ButtonSemanticProps = Omit<SemanticProps<ButtonValues>, keyof TextStyleProps | "width"> & TextStyleProps & {
395
+ /** Display width — a number/px pins the button; "100%" makes it full-width. */
396
+ width?: SizeInput;
397
+ };
341
398
  /**
342
399
  * Button - Universal SSR/Client Component with Automatic Semantic Props
343
400
  *
@@ -375,7 +432,7 @@ type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
375
432
  * </Button>
376
433
  * ```
377
434
  */
378
- declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>>;
435
+ declare const Button: React$1.FC<ItemComponentProps<ButtonSemanticProps>>;
379
436
 
380
437
  /**
381
438
  * Divider - Universal SSR/Client Component with Automatic Semantic Props
@@ -395,6 +452,18 @@ declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>
395
452
  */
396
453
  declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues>>>;
397
454
 
455
+ /**
456
+ * Heading semantic props — agent-friendly text/style types (replacing the loose
457
+ * `any` flat props) plus the `level` alias and h1–h6 levels.
458
+ */
459
+ type HeadingSemanticProps = Omit<SemanticProps<HeadingValues>, keyof TextStyleProps | "headingType"> & TextStyleProps & {
460
+ /** Heading level h1–h6. */
461
+ headingType?: HeadingLevel;
462
+ /** Alias for `headingType`. */
463
+ level?: HeadingLevel;
464
+ /** Heading text (or use children). */
465
+ text?: string;
466
+ };
398
467
  /**
399
468
  * Heading - Universal SSR/Client Component with Semantic Props API
400
469
  *
@@ -415,7 +484,7 @@ declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues
415
484
  * <Heading values={{ headingType: "h1", color: "#222" }}>Welcome</Heading>
416
485
  * ```
417
486
  */
418
- declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues>>>;
487
+ declare const Heading: React$1.FC<ItemComponentProps<HeadingSemanticProps>>;
419
488
 
420
489
  /**
421
490
  * Html - Universal SSR/Client Component for custom HTML with Automatic Semantic Props
@@ -432,9 +501,20 @@ declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues
432
501
  */
433
502
  declare const Html: React$1.FC<ItemComponentProps<SemanticProps<HtmlValues>>>;
434
503
 
435
- type ImageSemanticProps = SemanticProps<ImageValues> & {
504
+ /**
505
+ * Image semantic props — agent-friendly `src` (plain URL string or value object)
506
+ * and CSS-style sizing (number/px pins, "50%" sets a percentage), replacing the
507
+ * loose `any` flat props.
508
+ */
509
+ type ImageSemanticProps = Omit<SemanticProps<ImageValues>, "src" | "width" | "maxWidth"> & {
436
510
  /** Alt text (alias for altText) */
437
511
  alt?: string;
512
+ /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */
513
+ src?: ImageSrcInput;
514
+ /** Display width — number/px pins the image; "50%" sets a percentage width. */
515
+ width?: SizeInput;
516
+ /** Display width as a CSS value ("50%", "300px"). */
517
+ maxWidth?: SizeInput;
438
518
  };
439
519
  /**
440
520
  * Image - Renders an image element.
@@ -479,6 +559,14 @@ type MenuSemanticProps = SemanticProps<MenuValues> & {
479
559
  */
480
560
  declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
481
561
 
562
+ /**
563
+ * Paragraph semantic props — agent-friendly text/style types (replacing the
564
+ * loose `any` flat props) plus the `text` shorthand (converted to textJson).
565
+ */
566
+ type ParagraphSemanticProps = Omit<SemanticProps<ParagraphValues>, keyof TextStyleProps> & TextStyleProps & {
567
+ /** Plain-text content (or use `html` for inline formatting, or children). */
568
+ text?: string;
569
+ };
482
570
  /**
483
571
  * Paragraph - Universal SSR/Client Component with Semantic Props API
484
572
  *
@@ -499,7 +587,7 @@ declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
499
587
  * <Paragraph values={{ textJson: "...", color: "#555" }} />
500
588
  * ```
501
589
  */
502
- declare const Paragraph: React$1.FC<ItemComponentProps<SemanticProps<ParagraphValues>>>;
590
+ declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
503
591
 
504
592
  type SocialSemanticProps = SemanticProps<SocialValues> & {
505
593
  /** Social icons shorthand (array of {name, url}) */
@@ -578,7 +666,7 @@ type VideoSemanticProps = SemanticProps<VideoValues> & {
578
666
  */
579
667
  declare const Video: React$1.FC<ItemComponentProps<VideoSemanticProps>>;
580
668
 
581
- interface RowProps extends SemanticProps<RowValues> {
669
+ type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
582
670
  children?: React__default.ReactNode;
583
671
  layout?: ColumnLayout;
584
672
  cells?: number[];
@@ -588,12 +676,14 @@ interface RowProps extends SemanticProps<RowValues> {
588
676
  index?: number;
589
677
  bodyValues?: any;
590
678
  collection?: string;
679
+ /** Padding — a CSS string ("0 48px", "20px 40px") or a number (px). */
680
+ padding?: SizeInput;
591
681
  /** @internal - Unlayer config threaded from UnlayerProvider via Body */
592
682
  _config?: UnlayerConfig;
593
- }
683
+ };
594
684
  declare const Row: React__default.FC<RowProps>;
595
685
 
596
- interface ColumnProps extends SemanticProps<ColumnValues> {
686
+ type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding"> & {
597
687
  children?: React__default.ReactNode;
598
688
  index?: number;
599
689
  cells?: number[];
@@ -602,12 +692,14 @@ interface ColumnProps extends SemanticProps<ColumnValues> {
602
692
  mode?: RenderMode;
603
693
  className?: string;
604
694
  style?: React__default.CSSProperties;
695
+ /** Padding — a CSS string ("0 24px", "10px") or a number (px). */
696
+ padding?: SizeInput;
605
697
  /** @internal - Unlayer config threaded from UnlayerProvider via Body/Row */
606
698
  _config?: UnlayerConfig;
607
- }
699
+ };
608
700
  declare const Column: React__default.FC<ColumnProps>;
609
701
 
610
- interface BodyProps extends SemanticProps<BodyValues> {
702
+ type BodyProps = Omit<SemanticProps<BodyValues>, "padding"> & {
611
703
  children?: React__default.ReactNode;
612
704
  mode?: RenderMode;
613
705
  className?: string;
@@ -617,7 +709,9 @@ interface BodyProps extends SemanticProps<BodyValues> {
617
709
  config?: Partial<UnlayerConfig>;
618
710
  /** Preview text shown in email client inboxes (email mode only) */
619
711
  previewText?: string;
620
- }
712
+ /** Padding — a CSS string ("0 48px", "20px") or a number (px). */
713
+ padding?: SizeInput;
714
+ };
621
715
  /**
622
716
  * Body - Universal Server/Client Component
623
717
  *
package/dist/index.d.ts CHANGED
@@ -257,20 +257,69 @@ type ItemProps<TValues> = SemanticProps$1<TValues, React.ReactNode> & {
257
257
  style?: React.CSSProperties;
258
258
  mode?: "web" | "email" | "document";
259
259
  };
260
+ /** fontFamily accepts a ready stack object or a bare family-name string. */
261
+ type FontFamilyInput = {
262
+ label: string;
263
+ value: string;
264
+ } | string;
265
+ /** fontWeight accepts a number, a numeric string, or a CSS keyword. */
266
+ type FontWeightInput = number | `${number}` | "normal" | "bold" | "lighter" | "bolder";
267
+ /** A CSS size: a number (treated as px) or a string ("24px", "50%", "1.5em"). */
268
+ type SizeInput = number | (string & {});
269
+ /** Heading levels (h1–h6). */
270
+ type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
271
+ /** Shared text/style props, agent-friendly (replace the loose `any` flat keys). */
272
+ type TextStyleProps = {
273
+ fontFamily?: FontFamilyInput;
274
+ fontWeight?: FontWeightInput;
275
+ fontSize?: SizeInput;
276
+ lineHeight?: SizeInput;
277
+ /** Letter spacing — a CSS string ("0.5px", "-0.01em") or a number (px). */
278
+ letterSpacing?: SizeInput;
279
+ color?: string;
280
+ };
281
+ /** Image `src` accepts a plain URL string or the value object (loosened sizing). */
282
+ type ImageSrcInput = string | {
283
+ url: string;
284
+ width?: SizeInput;
285
+ height?: number;
286
+ autoWidth?: boolean;
287
+ maxWidth?: SizeInput;
288
+ [key: string]: unknown;
289
+ };
260
290
  /** Button component props */
261
- type ButtonProps = ItemProps<ButtonValues>;
291
+ type ButtonProps = Omit<ItemProps<ButtonValues>, keyof TextStyleProps | "width"> & TextStyleProps & {
292
+ /** Display width — a number/px pins the button; "100%" makes it full-width. */
293
+ width?: SizeInput;
294
+ };
262
295
  /** Heading component props */
263
- type HeadingProps = ItemProps<HeadingValues>;
296
+ type HeadingProps = Omit<ItemProps<HeadingValues>, keyof TextStyleProps | "headingType"> & TextStyleProps & {
297
+ /** Heading level h1–h6. */
298
+ headingType?: HeadingLevel;
299
+ /** Alias for `headingType`. */
300
+ level?: HeadingLevel;
301
+ /** Heading text (or use children). */
302
+ text?: string;
303
+ };
264
304
  /** Divider component props */
265
305
  type DividerProps = ItemProps<DividerValues>;
266
306
  /** HTML component props */
267
307
  type HtmlProps = ItemProps<HtmlValues>;
268
308
  /** Paragraph component props */
269
- type ParagraphProps = ItemProps<ParagraphValues>;
309
+ type ParagraphProps = Omit<ItemProps<ParagraphValues>, keyof TextStyleProps> & TextStyleProps & {
310
+ /** Plain-text content (or use `html` for inline formatting, or children). */
311
+ text?: string;
312
+ };
270
313
  /** Image component props — supports `alt` shorthand for `altText`. */
271
- type ImageProps = ItemProps<ImageValues> & {
314
+ type ImageProps = Omit<ItemProps<ImageValues>, "src" | "width" | "maxWidth"> & {
272
315
  /** Alt text (alias for altText) */
273
316
  alt?: string;
317
+ /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */
318
+ src?: ImageSrcInput;
319
+ /** Display width — number/px pins the image; "50%" sets a percentage width. */
320
+ width?: SizeInput;
321
+ /** Display width as a CSS value ("50%", "300px"). */
322
+ maxWidth?: SizeInput;
274
323
  };
275
324
  /** Social component props — supports `icons` shorthand array. */
276
325
  type SocialProps = ItemProps<SocialValues> & {
@@ -338,6 +387,14 @@ type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & TSemanticProp
338
387
  */
339
388
  type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
340
389
 
390
+ /**
391
+ * Button semantic props — agent-friendly text/style types (replacing the loose
392
+ * `any` flat props) plus a CSS-style `width` (number/px pins; "100%" full-width).
393
+ */
394
+ type ButtonSemanticProps = Omit<SemanticProps<ButtonValues>, keyof TextStyleProps | "width"> & TextStyleProps & {
395
+ /** Display width — a number/px pins the button; "100%" makes it full-width. */
396
+ width?: SizeInput;
397
+ };
341
398
  /**
342
399
  * Button - Universal SSR/Client Component with Automatic Semantic Props
343
400
  *
@@ -375,7 +432,7 @@ type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
375
432
  * </Button>
376
433
  * ```
377
434
  */
378
- declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>>;
435
+ declare const Button: React$1.FC<ItemComponentProps<ButtonSemanticProps>>;
379
436
 
380
437
  /**
381
438
  * Divider - Universal SSR/Client Component with Automatic Semantic Props
@@ -395,6 +452,18 @@ declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>
395
452
  */
396
453
  declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues>>>;
397
454
 
455
+ /**
456
+ * Heading semantic props — agent-friendly text/style types (replacing the loose
457
+ * `any` flat props) plus the `level` alias and h1–h6 levels.
458
+ */
459
+ type HeadingSemanticProps = Omit<SemanticProps<HeadingValues>, keyof TextStyleProps | "headingType"> & TextStyleProps & {
460
+ /** Heading level h1–h6. */
461
+ headingType?: HeadingLevel;
462
+ /** Alias for `headingType`. */
463
+ level?: HeadingLevel;
464
+ /** Heading text (or use children). */
465
+ text?: string;
466
+ };
398
467
  /**
399
468
  * Heading - Universal SSR/Client Component with Semantic Props API
400
469
  *
@@ -415,7 +484,7 @@ declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues
415
484
  * <Heading values={{ headingType: "h1", color: "#222" }}>Welcome</Heading>
416
485
  * ```
417
486
  */
418
- declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues>>>;
487
+ declare const Heading: React$1.FC<ItemComponentProps<HeadingSemanticProps>>;
419
488
 
420
489
  /**
421
490
  * Html - Universal SSR/Client Component for custom HTML with Automatic Semantic Props
@@ -432,9 +501,20 @@ declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues
432
501
  */
433
502
  declare const Html: React$1.FC<ItemComponentProps<SemanticProps<HtmlValues>>>;
434
503
 
435
- type ImageSemanticProps = SemanticProps<ImageValues> & {
504
+ /**
505
+ * Image semantic props — agent-friendly `src` (plain URL string or value object)
506
+ * and CSS-style sizing (number/px pins, "50%" sets a percentage), replacing the
507
+ * loose `any` flat props.
508
+ */
509
+ type ImageSemanticProps = Omit<SemanticProps<ImageValues>, "src" | "width" | "maxWidth"> & {
436
510
  /** Alt text (alias for altText) */
437
511
  alt?: string;
512
+ /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */
513
+ src?: ImageSrcInput;
514
+ /** Display width — number/px pins the image; "50%" sets a percentage width. */
515
+ width?: SizeInput;
516
+ /** Display width as a CSS value ("50%", "300px"). */
517
+ maxWidth?: SizeInput;
438
518
  };
439
519
  /**
440
520
  * Image - Renders an image element.
@@ -479,6 +559,14 @@ type MenuSemanticProps = SemanticProps<MenuValues> & {
479
559
  */
480
560
  declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
481
561
 
562
+ /**
563
+ * Paragraph semantic props — agent-friendly text/style types (replacing the
564
+ * loose `any` flat props) plus the `text` shorthand (converted to textJson).
565
+ */
566
+ type ParagraphSemanticProps = Omit<SemanticProps<ParagraphValues>, keyof TextStyleProps> & TextStyleProps & {
567
+ /** Plain-text content (or use `html` for inline formatting, or children). */
568
+ text?: string;
569
+ };
482
570
  /**
483
571
  * Paragraph - Universal SSR/Client Component with Semantic Props API
484
572
  *
@@ -499,7 +587,7 @@ declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
499
587
  * <Paragraph values={{ textJson: "...", color: "#555" }} />
500
588
  * ```
501
589
  */
502
- declare const Paragraph: React$1.FC<ItemComponentProps<SemanticProps<ParagraphValues>>>;
590
+ declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
503
591
 
504
592
  type SocialSemanticProps = SemanticProps<SocialValues> & {
505
593
  /** Social icons shorthand (array of {name, url}) */
@@ -578,7 +666,7 @@ type VideoSemanticProps = SemanticProps<VideoValues> & {
578
666
  */
579
667
  declare const Video: React$1.FC<ItemComponentProps<VideoSemanticProps>>;
580
668
 
581
- interface RowProps extends SemanticProps<RowValues> {
669
+ type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
582
670
  children?: React__default.ReactNode;
583
671
  layout?: ColumnLayout;
584
672
  cells?: number[];
@@ -588,12 +676,14 @@ interface RowProps extends SemanticProps<RowValues> {
588
676
  index?: number;
589
677
  bodyValues?: any;
590
678
  collection?: string;
679
+ /** Padding — a CSS string ("0 48px", "20px 40px") or a number (px). */
680
+ padding?: SizeInput;
591
681
  /** @internal - Unlayer config threaded from UnlayerProvider via Body */
592
682
  _config?: UnlayerConfig;
593
- }
683
+ };
594
684
  declare const Row: React__default.FC<RowProps>;
595
685
 
596
- interface ColumnProps extends SemanticProps<ColumnValues> {
686
+ type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding"> & {
597
687
  children?: React__default.ReactNode;
598
688
  index?: number;
599
689
  cells?: number[];
@@ -602,12 +692,14 @@ interface ColumnProps extends SemanticProps<ColumnValues> {
602
692
  mode?: RenderMode;
603
693
  className?: string;
604
694
  style?: React__default.CSSProperties;
695
+ /** Padding — a CSS string ("0 24px", "10px") or a number (px). */
696
+ padding?: SizeInput;
605
697
  /** @internal - Unlayer config threaded from UnlayerProvider via Body/Row */
606
698
  _config?: UnlayerConfig;
607
- }
699
+ };
608
700
  declare const Column: React__default.FC<ColumnProps>;
609
701
 
610
- interface BodyProps extends SemanticProps<BodyValues> {
702
+ type BodyProps = Omit<SemanticProps<BodyValues>, "padding"> & {
611
703
  children?: React__default.ReactNode;
612
704
  mode?: RenderMode;
613
705
  className?: string;
@@ -617,7 +709,9 @@ interface BodyProps extends SemanticProps<BodyValues> {
617
709
  config?: Partial<UnlayerConfig>;
618
710
  /** Preview text shown in email client inboxes (email mode only) */
619
711
  previewText?: string;
620
- }
712
+ /** Padding — a CSS string ("0 48px", "20px") or a number (px). */
713
+ padding?: SizeInput;
714
+ };
621
715
  /**
622
716
  * Body - Universal Server/Client Component
623
717
  *