@unlayer/react-elements 0.1.9 → 0.1.11

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
@@ -1,5 +1,7 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default from 'react';
3
+ import { ColumnValues } from '@unlayer/types/containers/column';
4
+ export { ColumnValues } from '@unlayer/types/containers/column';
3
5
  import { ButtonValues } from '@unlayer/types/tools/button';
4
6
  export { ButtonValues } from '@unlayer/types/tools/button';
5
7
  import { DividerValues } from '@unlayer/types/tools/divider';
@@ -22,8 +24,6 @@ import { VideoValues } from '@unlayer/types/tools/video';
22
24
  export { VideoValues } from '@unlayer/types/tools/video';
23
25
  import { RowValues } from '@unlayer/types/containers/row';
24
26
  export { RowValues } from '@unlayer/types/containers/row';
25
- import { ColumnValues } from '@unlayer/types/containers/column';
26
- export { ColumnValues } from '@unlayer/types/containers/column';
27
27
  import { BodyValues } from '@unlayer/types/containers/body';
28
28
  export { BodyValues } from '@unlayer/types/containers/body';
29
29
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -243,58 +243,53 @@ type SemanticProps$1<T, TChildren = any> = FlattenObjectProps<T> & {
243
243
  /**
244
244
  * Type Definitions
245
245
  *
246
- * Re-exports shared types from @unlayer-internal/shared-elements
247
- * and defines React-specific component prop types.
246
+ * Re-exports the canonical value types from @unlayer-internal/shared-elements
247
+ * and defines the agent-friendly input types components build their props from.
248
+ *
249
+ * Each component's prop type (ButtonProps, HeadingProps, …) lives next to its
250
+ * component — these are just the shared building blocks they share.
248
251
  */
249
252
 
253
+ /** fontFamily accepts a ready stack object or a bare family-name string. */
254
+ type FontFamilyInput = {
255
+ label: string;
256
+ value: string;
257
+ } | string;
258
+ /** fontWeight accepts a number, a numeric string, or a CSS keyword. */
259
+ type FontWeightInput = number | `${number}` | "normal" | "bold" | "lighter" | "bolder";
260
+ /** A CSS size: a number (treated as px) or a string ("24px", "50%", "1.5em"). */
261
+ type SizeInput = number | (string & {});
250
262
  /**
251
- * Public props for item components.
252
- * Includes semantic flat props, children, values escape hatch,
253
- * className, style, and mode. Excludes internal threading props.
263
+ * The `border` object, agent-friendly. The canonical type pins each per-side
264
+ * `*Width` to `${number}px`, so a literal like "1px" type-checks inline but a
265
+ * factored-out object widens "1px" to `string` and stops compiling exactly the
266
+ * reusable-divider pattern authors reach for. Relax the `*Width` fields to
267
+ * SizeInput (the runtime accepts any CSS string), derived from the canonical
268
+ * shape so it tracks the schema instead of duplicating it.
254
269
  */
255
- type ItemProps<TValues> = SemanticProps$1<TValues, React.ReactNode> & {
256
- className?: string;
257
- style?: React.CSSProperties;
258
- mode?: "web" | "email" | "document";
259
- };
260
- /** Button component props */
261
- type ButtonProps = ItemProps<ButtonValues>;
262
- /** Heading component props */
263
- type HeadingProps = ItemProps<HeadingValues>;
264
- /** Divider component props */
265
- type DividerProps = ItemProps<DividerValues>;
266
- /** HTML component props */
267
- type HtmlProps = ItemProps<HtmlValues>;
268
- /** Paragraph component props */
269
- type ParagraphProps = ItemProps<ParagraphValues>;
270
- /** Image component props — supports `alt` shorthand for `altText`. */
271
- type ImageProps = ItemProps<ImageValues> & {
272
- /** Alt text (alias for altText) */
273
- alt?: string;
274
- };
275
- /** Social component props — supports `icons` shorthand array. */
276
- type SocialProps = ItemProps<SocialValues> & {
277
- /** Social icons shorthand */
278
- icons?: SocialIcon[];
279
- /** Icon shape */
280
- iconType?: "circle" | "rounded" | "squared";
281
- };
282
- /** Menu component props — supports `items` shorthand array. */
283
- type MenuProps = ItemProps<MenuValues> & {
284
- /** Menu items shorthand */
285
- items?: MenuItem[];
270
+ type BorderInput = {
271
+ [K in keyof NonNullable<ColumnValues["border"]>]?: K extends `${string}Width` ? SizeInput : NonNullable<ColumnValues["border"]>[K];
286
272
  };
287
- /** Table component props — supports `headers` + `data` shorthands. */
288
- type TableProps = ItemProps<TableValues> & {
289
- /** Column headers */
290
- headers?: string[];
291
- /** Row data as 2D array */
292
- data?: string[][];
273
+ /** Heading levels (h1–h6). */
274
+ type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
275
+ /** Shared text/style inputs, agent-friendly. */
276
+ type TextStyleProps = {
277
+ fontFamily?: FontFamilyInput;
278
+ fontWeight?: FontWeightInput;
279
+ fontSize?: SizeInput;
280
+ lineHeight?: SizeInput;
281
+ /** Letter spacing — a CSS string ("0.5px", "-0.01em") or a number (px). */
282
+ letterSpacing?: SizeInput;
283
+ color?: string;
293
284
  };
294
- /** Video component props supports `videoUrl` shorthand. */
295
- type VideoProps = ItemProps<VideoValues> & {
296
- /** YouTube/Vimeo URL (auto-parsed) */
297
- videoUrl?: string;
285
+ /** Image `src` accepts a plain URL string or the value object (loosened sizing). */
286
+ type ImageSrcInput = string | {
287
+ url: string;
288
+ width?: SizeInput;
289
+ height?: number;
290
+ autoWidth?: boolean;
291
+ maxWidth?: SizeInput;
292
+ [key: string]: unknown;
298
293
  };
299
294
 
300
295
  /**
@@ -338,6 +333,26 @@ type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & TSemanticProp
338
333
  */
339
334
  type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
340
335
 
336
+ /**
337
+ * Button semantic props — agent-friendly text/style types (replacing the loose
338
+ * `any` flat props) plus a CSS-style `width` (number/px pins; "100%" full-width).
339
+ */
340
+ type ButtonSemanticProps = Omit<SemanticProps<ButtonValues>, keyof TextStyleProps | "width" | "padding" | "borderRadius" | "border"> & TextStyleProps & {
341
+ /** Display width — a number/px pins the button; "100%" makes it full-width. */
342
+ width?: SizeInput;
343
+ /** Inner padding — a number (→ px) or CSS string ("14px 28px"). */
344
+ padding?: SizeInput;
345
+ /** Corner radius — a number (→ px) or CSS string ("8px", "500px"). */
346
+ borderRadius?: SizeInput;
347
+ /** Per-side border object (width fields accept a number/px string). */
348
+ border?: BorderInput;
349
+ };
350
+ /**
351
+ * Button Component Props
352
+ * Automatically provides autocomplete for ALL properties (flat and nested)
353
+ */
354
+ interface ButtonProps extends ItemComponentProps<ButtonSemanticProps> {
355
+ }
341
356
  /**
342
357
  * Button - Universal SSR/Client Component with Automatic Semantic Props
343
358
  *
@@ -375,8 +390,14 @@ type SemanticProps<T> = SemanticProps$1<T, React.ReactNode>;
375
390
  * </Button>
376
391
  * ```
377
392
  */
378
- declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>>;
393
+ declare const Button: React$1.FC<ItemComponentProps<ButtonSemanticProps>>;
379
394
 
395
+ type DividerSemanticProps = Omit<SemanticProps<DividerValues>, "border"> & {
396
+ /** Per-side border object (width fields accept a number/px string). */
397
+ border?: BorderInput;
398
+ };
399
+ interface DividerProps extends ItemComponentProps<DividerSemanticProps> {
400
+ }
380
401
  /**
381
402
  * Divider - Universal SSR/Client Component with Automatic Semantic Props
382
403
  *
@@ -393,8 +414,26 @@ declare const Button: React$1.FC<ItemComponentProps<SemanticProps<ButtonValues>>
393
414
  * }} />
394
415
  * ```
395
416
  */
396
- declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues>>>;
417
+ declare const Divider: React$1.FC<ItemComponentProps<DividerSemanticProps>>;
397
418
 
419
+ /**
420
+ * Heading semantic props — agent-friendly text/style types (replacing the loose
421
+ * `any` flat props) plus the `level` alias and h1–h6 levels.
422
+ */
423
+ type HeadingSemanticProps = Omit<SemanticProps<HeadingValues>, keyof TextStyleProps | "headingType"> & TextStyleProps & {
424
+ /** Heading level h1–h6. */
425
+ headingType?: HeadingLevel;
426
+ /** Alias for `headingType`. */
427
+ level?: HeadingLevel;
428
+ /** Heading text (or use children). */
429
+ text?: string;
430
+ };
431
+ /**
432
+ * Heading Component Props
433
+ * Automatically provides autocomplete for ALL properties (flat and nested)
434
+ */
435
+ interface HeadingProps extends ItemComponentProps<HeadingSemanticProps> {
436
+ }
398
437
  /**
399
438
  * Heading - Universal SSR/Client Component with Semantic Props API
400
439
  *
@@ -415,8 +454,10 @@ declare const Divider: React$1.FC<ItemComponentProps<SemanticProps<DividerValues
415
454
  * <Heading values={{ headingType: "h1", color: "#222" }}>Welcome</Heading>
416
455
  * ```
417
456
  */
418
- declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues>>>;
457
+ declare const Heading: React$1.FC<ItemComponentProps<HeadingSemanticProps>>;
419
458
 
459
+ interface HtmlProps extends ItemComponentProps<SemanticProps<HtmlValues>> {
460
+ }
420
461
  /**
421
462
  * Html - Universal SSR/Client Component for custom HTML with Automatic Semantic Props
422
463
  *
@@ -432,10 +473,23 @@ declare const Heading: React$1.FC<ItemComponentProps<SemanticProps<HeadingValues
432
473
  */
433
474
  declare const Html: React$1.FC<ItemComponentProps<SemanticProps<HtmlValues>>>;
434
475
 
435
- type ImageSemanticProps = SemanticProps<ImageValues> & {
476
+ /**
477
+ * Image semantic props — agent-friendly `src` (plain URL string or value object)
478
+ * and CSS-style sizing (number/px pins, "50%" sets a percentage), replacing the
479
+ * loose `any` flat props.
480
+ */
481
+ type ImageSemanticProps = Omit<SemanticProps<ImageValues>, "src" | "width" | "maxWidth"> & {
436
482
  /** Alt text (alias for altText) */
437
483
  alt?: string;
484
+ /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */
485
+ src?: ImageSrcInput;
486
+ /** Display width — number/px pins the image; "50%" sets a percentage width. */
487
+ width?: SizeInput;
488
+ /** Display width as a CSS value ("50%", "300px"). */
489
+ maxWidth?: SizeInput;
438
490
  };
491
+ interface ImageProps extends ItemComponentProps<ImageSemanticProps> {
492
+ }
439
493
  /**
440
494
  * Image - Renders an image element.
441
495
  *
@@ -454,10 +508,14 @@ type ImageSemanticProps = SemanticProps<ImageValues> & {
454
508
  */
455
509
  declare const Image: React$1.FC<ItemComponentProps<ImageSemanticProps>>;
456
510
 
457
- type MenuSemanticProps = SemanticProps<MenuValues> & {
511
+ type MenuSemanticProps = Omit<SemanticProps<MenuValues>, "padding"> & {
458
512
  /** Menu items shorthand */
459
513
  items?: MenuItem[];
514
+ /** Inner padding — a number (→ px) or CSS string. */
515
+ padding?: SizeInput;
460
516
  };
517
+ interface MenuProps extends ItemComponentProps<MenuSemanticProps> {
518
+ }
461
519
  /**
462
520
  * Menu - Renders a navigation menu.
463
521
  *
@@ -479,6 +537,20 @@ type MenuSemanticProps = SemanticProps<MenuValues> & {
479
537
  */
480
538
  declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
481
539
 
540
+ /**
541
+ * Paragraph semantic props — agent-friendly text/style types (replacing the
542
+ * loose `any` flat props) plus the `text` shorthand (converted to textJson).
543
+ */
544
+ type ParagraphSemanticProps = Omit<SemanticProps<ParagraphValues>, keyof TextStyleProps> & TextStyleProps & {
545
+ /** Plain-text content (or use `html` for inline formatting, or children). */
546
+ text?: string;
547
+ };
548
+ /**
549
+ * Paragraph Component Props
550
+ * Automatically provides autocomplete for ALL properties (flat and nested)
551
+ */
552
+ interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {
553
+ }
482
554
  /**
483
555
  * Paragraph - Universal SSR/Client Component with Semantic Props API
484
556
  *
@@ -499,7 +571,7 @@ declare const Menu: React$1.FC<ItemComponentProps<MenuSemanticProps>>;
499
571
  * <Paragraph values={{ textJson: "...", color: "#555" }} />
500
572
  * ```
501
573
  */
502
- declare const Paragraph: React$1.FC<ItemComponentProps<SemanticProps<ParagraphValues>>>;
574
+ declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
503
575
 
504
576
  type SocialSemanticProps = SemanticProps<SocialValues> & {
505
577
  /** Social icons shorthand (array of {name, url}) */
@@ -507,6 +579,10 @@ type SocialSemanticProps = SemanticProps<SocialValues> & {
507
579
  /** Icon shape */
508
580
  iconType?: "circle" | "rounded" | "squared";
509
581
  };
582
+ interface SocialProps extends Omit<ItemComponentProps<SemanticProps<SocialValues>>, "icons"> {
583
+ icons?: SocialIcon[] | SocialValues["icons"];
584
+ iconType?: "circle" | "rounded" | "squared";
585
+ }
510
586
  /**
511
587
  * Social - Renders social-media icon links.
512
588
  *
@@ -527,12 +603,24 @@ type SocialSemanticProps = SemanticProps<SocialValues> & {
527
603
  */
528
604
  declare const Social: React$1.FC<ItemComponentProps<SocialSemanticProps>>;
529
605
 
530
- type TableSemanticProps = SemanticProps<TableValues> & {
606
+ type TableSemanticProps = Omit<SemanticProps<TableValues>, "padding" | "border"> & {
531
607
  /** Column headers as string[] */
532
608
  headers?: string[];
533
609
  /** Row data as 2D string array */
534
610
  data?: string[][];
611
+ /** Inner padding — a number (→ px) or CSS string. */
612
+ padding?: SizeInput;
613
+ /** Per-side border object (width fields accept a number/px string). */
614
+ border?: BorderInput;
535
615
  };
616
+ interface TableProps extends Omit<ItemComponentProps<Omit<SemanticProps<TableValues>, "padding" | "border">>, "headers" | "data"> {
617
+ headers?: string[];
618
+ data?: string[][];
619
+ /** Inner padding — a number (→ px) or CSS string. */
620
+ padding?: SizeInput;
621
+ /** Per-side border object (width fields accept a number/px string). */
622
+ border?: BorderInput;
623
+ }
536
624
  /**
537
625
  * Table - Renders a data table.
538
626
  *
@@ -561,6 +649,9 @@ type VideoSemanticProps = SemanticProps<VideoValues> & {
561
649
  /** YouTube/Vimeo URL (auto-parsed) */
562
650
  videoUrl?: string;
563
651
  };
652
+ interface VideoProps extends ItemComponentProps<SemanticProps<VideoValues>> {
653
+ videoUrl?: string;
654
+ }
564
655
  /**
565
656
  * Video - Renders an embedded video player (YouTube/Vimeo).
566
657
  *
@@ -578,7 +669,7 @@ type VideoSemanticProps = SemanticProps<VideoValues> & {
578
669
  */
579
670
  declare const Video: React$1.FC<ItemComponentProps<VideoSemanticProps>>;
580
671
 
581
- interface RowProps extends SemanticProps<RowValues> {
672
+ type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
582
673
  children?: React__default.ReactNode;
583
674
  layout?: ColumnLayout;
584
675
  cells?: number[];
@@ -588,12 +679,14 @@ interface RowProps extends SemanticProps<RowValues> {
588
679
  index?: number;
589
680
  bodyValues?: any;
590
681
  collection?: string;
682
+ /** Padding — a CSS string ("0 48px", "20px 40px") or a number (px). */
683
+ padding?: SizeInput;
591
684
  /** @internal - Unlayer config threaded from UnlayerProvider via Body */
592
685
  _config?: UnlayerConfig;
593
- }
686
+ };
594
687
  declare const Row: React__default.FC<RowProps>;
595
688
 
596
- interface ColumnProps extends SemanticProps<ColumnValues> {
689
+ type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding" | "border" | "borderRadius"> & {
597
690
  children?: React__default.ReactNode;
598
691
  index?: number;
599
692
  cells?: number[];
@@ -602,12 +695,19 @@ interface ColumnProps extends SemanticProps<ColumnValues> {
602
695
  mode?: RenderMode;
603
696
  className?: string;
604
697
  style?: React__default.CSSProperties;
698
+ /** Padding — a CSS string ("0 24px", "10px") or a number (px). */
699
+ padding?: SizeInput;
700
+ /** Corner radius — a number (→ px) or CSS string ("8px"). */
701
+ borderRadius?: SizeInput;
702
+ /** Per-side border object (great for hairline dividers). Width fields accept
703
+ * a number/px string; reuse it as a factored-out const without `as const`. */
704
+ border?: BorderInput;
605
705
  /** @internal - Unlayer config threaded from UnlayerProvider via Body/Row */
606
706
  _config?: UnlayerConfig;
607
- }
707
+ };
608
708
  declare const Column: React__default.FC<ColumnProps>;
609
709
 
610
- interface BodyProps extends SemanticProps<BodyValues> {
710
+ type BodyProps = Omit<SemanticProps<BodyValues>, "padding" | "borderRadius"> & {
611
711
  children?: React__default.ReactNode;
612
712
  mode?: RenderMode;
613
713
  className?: string;
@@ -617,7 +717,11 @@ interface BodyProps extends SemanticProps<BodyValues> {
617
717
  config?: Partial<UnlayerConfig>;
618
718
  /** Preview text shown in email client inboxes (email mode only) */
619
719
  previewText?: string;
620
- }
720
+ /** Padding — a CSS string ("0 48px", "20px") or a number (px). */
721
+ padding?: SizeInput;
722
+ /** Corner radius — a number (→ px) or CSS string ("8px"). */
723
+ borderRadius?: SizeInput;
724
+ };
621
725
  /**
622
726
  * Body - Universal Server/Client Component
623
727
  *