@unlayer/react-elements 0.1.21 → 0.1.22

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
@@ -16,6 +16,8 @@ import { MenuValues } from '@unlayer/types/tools/menu';
16
16
  export { MenuValues } from '@unlayer/types/tools/menu';
17
17
  import { ParagraphValues } from '@unlayer/types/tools/paragraph';
18
18
  export { ParagraphValues } from '@unlayer/types/tools/paragraph';
19
+ import { PageBreakValues } from '@unlayer/types/tools/page-break';
20
+ export { PageBreakValues } from '@unlayer/types/tools/page-break';
19
21
  import { SocialValues } from '@unlayer/types/tools/social';
20
22
  export { SocialValues } from '@unlayer/types/tools/social';
21
23
  import { TableValues } from '@unlayer/types/tools/table';
@@ -592,6 +594,15 @@ interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {
592
594
  */
593
595
  declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
594
596
 
597
+ type PageBreakProps = ItemComponentProps<SemanticProps<PageBreakValues>>;
598
+ /**
599
+ * PageBreak - Forces subsequent document content onto a new PDF page.
600
+ *
601
+ * Page breaks render only in document mode. In email and web output they are
602
+ * intentionally inert.
603
+ */
604
+ declare const PageBreak: React$1.FC<ItemComponentProps<SemanticProps<PageBreakValues>>>;
605
+
595
606
  type SocialSemanticProps = Omit<SemanticProps<SocialValues>, "iconSize" | "spacing"> & {
596
607
  /** Social icons shorthand (array of {name, url}) */
597
608
  icons?: SocialIcon[];
@@ -806,7 +817,12 @@ declare namespace Page {
806
817
  var displayName: string;
807
818
  }
808
819
 
809
- type DocumentProps = Omit<BodyProps, "mode">;
820
+ type DocumentPageSize = "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid";
821
+ type DocumentOrientation = "portrait" | "landscape";
822
+ type DocumentProps = Omit<BodyProps, "mode" | "documentSize" | "documentOrientation" | "documentMargin"> & {
823
+ documentSize?: DocumentPageSize;
824
+ documentOrientation?: DocumentOrientation;
825
+ };
810
826
  /**
811
827
  * Document - Print-optimized rendering for PDF generation.
812
828
  *
@@ -814,7 +830,12 @@ type DocumentProps = Omit<BodyProps, "mode">;
814
830
  *
815
831
  * @example
816
832
  * ```tsx
817
- * <Document backgroundColor="#ffffff" contentWidth="700px">
833
+ * <Document
834
+ * backgroundColor="#ffffff"
835
+ * contentWidth="700px"
836
+ * documentSize="A4"
837
+ * documentOrientation="portrait"
838
+ * >
818
839
  * <Row><Column><Paragraph text="Hello" /></Column></Row>
819
840
  * </Document>
820
841
  * ```
@@ -1126,4 +1147,4 @@ declare function registerTool(tool: ElementsToolConfig): React__default.FC<Eleme
1126
1147
  /** Alias of {@link registerTool}. */
1127
1148
  declare const registerElementsTool: typeof registerTool;
1128
1149
 
1129
- export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
1150
+ export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentOrientation, type DocumentPageSize, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, PageBreak, type PageBreakProps, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ import { MenuValues } from '@unlayer/types/tools/menu';
16
16
  export { MenuValues } from '@unlayer/types/tools/menu';
17
17
  import { ParagraphValues } from '@unlayer/types/tools/paragraph';
18
18
  export { ParagraphValues } from '@unlayer/types/tools/paragraph';
19
+ import { PageBreakValues } from '@unlayer/types/tools/page-break';
20
+ export { PageBreakValues } from '@unlayer/types/tools/page-break';
19
21
  import { SocialValues } from '@unlayer/types/tools/social';
20
22
  export { SocialValues } from '@unlayer/types/tools/social';
21
23
  import { TableValues } from '@unlayer/types/tools/table';
@@ -592,6 +594,15 @@ interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {
592
594
  */
593
595
  declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
594
596
 
597
+ type PageBreakProps = ItemComponentProps<SemanticProps<PageBreakValues>>;
598
+ /**
599
+ * PageBreak - Forces subsequent document content onto a new PDF page.
600
+ *
601
+ * Page breaks render only in document mode. In email and web output they are
602
+ * intentionally inert.
603
+ */
604
+ declare const PageBreak: React$1.FC<ItemComponentProps<SemanticProps<PageBreakValues>>>;
605
+
595
606
  type SocialSemanticProps = Omit<SemanticProps<SocialValues>, "iconSize" | "spacing"> & {
596
607
  /** Social icons shorthand (array of {name, url}) */
597
608
  icons?: SocialIcon[];
@@ -806,7 +817,12 @@ declare namespace Page {
806
817
  var displayName: string;
807
818
  }
808
819
 
809
- type DocumentProps = Omit<BodyProps, "mode">;
820
+ type DocumentPageSize = "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid";
821
+ type DocumentOrientation = "portrait" | "landscape";
822
+ type DocumentProps = Omit<BodyProps, "mode" | "documentSize" | "documentOrientation" | "documentMargin"> & {
823
+ documentSize?: DocumentPageSize;
824
+ documentOrientation?: DocumentOrientation;
825
+ };
810
826
  /**
811
827
  * Document - Print-optimized rendering for PDF generation.
812
828
  *
@@ -814,7 +830,12 @@ type DocumentProps = Omit<BodyProps, "mode">;
814
830
  *
815
831
  * @example
816
832
  * ```tsx
817
- * <Document backgroundColor="#ffffff" contentWidth="700px">
833
+ * <Document
834
+ * backgroundColor="#ffffff"
835
+ * contentWidth="700px"
836
+ * documentSize="A4"
837
+ * documentOrientation="portrait"
838
+ * >
818
839
  * <Row><Column><Paragraph text="Hello" /></Column></Row>
819
840
  * </Document>
820
841
  * ```
@@ -1126,4 +1147,4 @@ declare function registerTool(tool: ElementsToolConfig): React__default.FC<Eleme
1126
1147
  /** Alias of {@link registerTool}. */
1127
1148
  declare const registerElementsTool: typeof registerTool;
1128
1149
 
1129
- export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
1150
+ export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentOrientation, type DocumentPageSize, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, PageBreak, type PageBreakProps, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
package/dist/index.js CHANGED
@@ -796,7 +796,8 @@ function createItemComponent(config) {
796
796
  contentType: config.contentType,
797
797
  slug: config.slug,
798
798
  metaName: config.metaName,
799
- head: config.head
799
+ head: config.head,
800
+ omitEmptyOutput: config.omitEmptyOutput
800
801
  };
801
802
  return ItemComponent;
802
803
  }
@@ -1008,13 +1009,45 @@ var Paragraph = createItemComponent({
1008
1009
  exporters: ParagraphExporters
1009
1010
  });
1010
1011
  var Paragraph_default = Paragraph;
1011
- var DEFAULT_ICONS = SocialDefaults.icons ?? { iconType: "circle", icons: [] };
1012
+
1013
+ // src/components/PageBreak.tsx
1012
1014
  var DEFAULT_VALUES8 = {
1015
+ color: "#6b7280"
1016
+ };
1017
+ var pageBreakExporters = {
1018
+ // Page breaks are a document-only concept. Keep the unsupported renderers
1019
+ // inert so a component rendered outside <Document> does not throw.
1020
+ web: () => "",
1021
+ email: () => "",
1022
+ document: () => '<div class="u-content-page-break" aria-hidden="true"></div>'
1023
+ };
1024
+ var pageBreakHead = {
1025
+ css: (_values, _bodyValues, meta) => meta.displayMode === "document" ? `
1026
+ .u-content-page-break {
1027
+ break-after: page;
1028
+ page-break-after: always;
1029
+ }
1030
+ ` : void 0
1031
+ };
1032
+ var PageBreak = createItemComponent({
1033
+ name: "PageBreak",
1034
+ contentType: "page_break",
1035
+ metaName: "page_break",
1036
+ defaultValues: DEFAULT_VALUES8,
1037
+ propMapper: (props) => mapSemanticProps(props, DEFAULT_VALUES8, "PageBreak"),
1038
+ displayName: "PageBreak",
1039
+ exporters: pageBreakExporters,
1040
+ head: pageBreakHead,
1041
+ omitEmptyOutput: true
1042
+ });
1043
+ var PageBreak_default = PageBreak;
1044
+ var DEFAULT_ICONS = SocialDefaults.icons ?? { iconType: "circle", icons: [] };
1045
+ var DEFAULT_VALUES9 = {
1013
1046
  ...SocialDefaults
1014
1047
  };
1015
1048
  var Social = createItemComponent({
1016
1049
  name: "Social",
1017
- defaultValues: DEFAULT_VALUES8,
1050
+ defaultValues: DEFAULT_VALUES9,
1018
1051
  propMapper: (props) => {
1019
1052
  const { icons, iconType, ...rest } = props;
1020
1053
  const coerceSizes = (base) => {
@@ -1035,7 +1068,7 @@ var Social = createItemComponent({
1035
1068
  }));
1036
1069
  const base = mapSemanticProps(
1037
1070
  rest,
1038
- DEFAULT_VALUES8,
1071
+ DEFAULT_VALUES9,
1039
1072
  "Social"
1040
1073
  );
1041
1074
  base.icons = {
@@ -1047,14 +1080,14 @@ var Social = createItemComponent({
1047
1080
  if (iconType !== void 0) {
1048
1081
  const base = mapSemanticProps(
1049
1082
  rest,
1050
- DEFAULT_VALUES8,
1083
+ DEFAULT_VALUES9,
1051
1084
  "Social"
1052
1085
  );
1053
1086
  base.icons = { ...DEFAULT_ICONS, ...base.icons, iconType };
1054
1087
  return coerceSizes(base);
1055
1088
  }
1056
1089
  return coerceSizes(
1057
- mapSemanticProps(props, DEFAULT_VALUES8, "Social")
1090
+ mapSemanticProps(props, DEFAULT_VALUES9, "Social")
1058
1091
  );
1059
1092
  },
1060
1093
  displayName: "Social",
@@ -1062,20 +1095,20 @@ var Social = createItemComponent({
1062
1095
  });
1063
1096
  var Social_default = Social;
1064
1097
  var DEFAULT_TABLE = { headers: [], rows: [], footers: [] };
1065
- var DEFAULT_VALUES9 = {
1098
+ var DEFAULT_VALUES10 = {
1066
1099
  ...TableDefaults,
1067
1100
  table: DEFAULT_TABLE
1068
1101
  // Schema doesn't include table data structure
1069
1102
  };
1070
1103
  var Table = createItemComponent({
1071
1104
  name: "Table",
1072
- defaultValues: DEFAULT_VALUES9,
1105
+ defaultValues: DEFAULT_VALUES10,
1073
1106
  propMapper: (props) => {
1074
1107
  const { headers, data, columns, rows, ...rest } = props;
1075
1108
  if (headers || data || typeof columns === "number" || typeof rows === "number") {
1076
1109
  const base = mapSemanticProps(
1077
1110
  rest,
1078
- DEFAULT_VALUES9,
1111
+ DEFAULT_VALUES10,
1079
1112
  "Table"
1080
1113
  );
1081
1114
  const colCount = headers ? headers.length : typeof columns === "number" ? columns : data?.[0]?.length ?? 0;
@@ -1107,7 +1140,7 @@ var Table = createItemComponent({
1107
1140
  }
1108
1141
  return mapSemanticProps(
1109
1142
  props,
1110
- DEFAULT_VALUES9,
1143
+ DEFAULT_VALUES10,
1111
1144
  "Table"
1112
1145
  );
1113
1146
  },
@@ -1122,7 +1155,7 @@ var DEFAULT_VIDEO = {
1122
1155
  loading: false,
1123
1156
  ...VideoDefaults.video
1124
1157
  };
1125
- var DEFAULT_VALUES10 = {
1158
+ var DEFAULT_VALUES11 = {
1126
1159
  ...VideoDefaults,
1127
1160
  video: DEFAULT_VIDEO
1128
1161
  };
@@ -1150,14 +1183,14 @@ function parseVideoUrl(url) {
1150
1183
  }
1151
1184
  var Video = createItemComponent({
1152
1185
  name: "Video",
1153
- defaultValues: DEFAULT_VALUES10,
1186
+ defaultValues: DEFAULT_VALUES11,
1154
1187
  propMapper: (props) => {
1155
1188
  const { videoUrl, ...rest } = props;
1156
1189
  if (typeof videoUrl === "string") {
1157
1190
  const parsed = parseVideoUrl(videoUrl);
1158
1191
  const base = mapSemanticProps(
1159
1192
  rest,
1160
- DEFAULT_VALUES10,
1193
+ DEFAULT_VALUES11,
1161
1194
  "Video"
1162
1195
  );
1163
1196
  if (parsed) {
@@ -1167,7 +1200,7 @@ var Video = createItemComponent({
1167
1200
  }
1168
1201
  return mapSemanticProps(
1169
1202
  props,
1170
- DEFAULT_VALUES10,
1203
+ DEFAULT_VALUES11,
1171
1204
  "Video"
1172
1205
  );
1173
1206
  },
@@ -1195,7 +1228,7 @@ var {
1195
1228
  var BODY_DEFAULTS = bodyRest;
1196
1229
  var ROW_DEFAULTS = { ...RowDefaults };
1197
1230
  var COLUMN_DEFAULTS = { ...ColumnDefaults };
1198
- var DEFAULT_VALUES11 = ROW_DEFAULTS;
1231
+ var DEFAULT_VALUES12 = ROW_DEFAULTS;
1199
1232
  var DEFAULT_BODY_VALUES = BODY_DEFAULTS;
1200
1233
  function getWidthPercentages(cells) {
1201
1234
  if (cells.length === 0) return [];
@@ -1333,7 +1366,7 @@ var Row = (props) => {
1333
1366
  const safeBodyValues = { ...DEFAULT_BODY_VALUES, ...bodyValues };
1334
1367
  const values = mapSemanticProps(
1335
1368
  semanticProps,
1336
- DEFAULT_VALUES11,
1369
+ DEFAULT_VALUES12,
1337
1370
  "Row"
1338
1371
  );
1339
1372
  const valuesWithMeta = {
@@ -1371,7 +1404,7 @@ var Row = (props) => {
1371
1404
  Row.displayName = "Row";
1372
1405
  var Row_default = Row;
1373
1406
  var DEFAULT_CONTAINER_PADDING2 = "10px";
1374
- var DEFAULT_VALUES12 = COLUMN_DEFAULTS;
1407
+ var DEFAULT_VALUES13 = COLUMN_DEFAULTS;
1375
1408
  function renderColumnToHtml(innerHTML, values, index, cells, bodyValues, rowValues, mode) {
1376
1409
  const columnExporter = ColumnExporters[mode] || ColumnExporters.web;
1377
1410
  return columnExporter(innerHTML, values, index, cells, bodyValues, rowValues);
@@ -1396,7 +1429,7 @@ var Column = (props) => {
1396
1429
  const mode = modeProp ?? _config?.mode ?? "web";
1397
1430
  const values = mapSemanticProps(
1398
1431
  semanticProps,
1399
- DEFAULT_VALUES12,
1432
+ DEFAULT_VALUES13,
1400
1433
  "Column"
1401
1434
  );
1402
1435
  const valuesWithMeta = {
@@ -1432,6 +1465,7 @@ var Column = (props) => {
1432
1465
  });
1433
1466
  if (rendered && typeof rendered === "object" && rendered.props && rendered.props.dangerouslySetInnerHTML) {
1434
1467
  const componentHTML = rendered.props.dangerouslySetInnerHTML.__html;
1468
+ if (!componentHTML && ComponentType?.[UNLAYER_CONFIG_KEY]?.omitEmptyOutput) return;
1435
1469
  const childProps = child.props;
1436
1470
  const rawContainerPadding = childProps.containerPadding ?? childProps.values?.containerPadding ?? DEFAULT_CONTAINER_PADDING2;
1437
1471
  const containerPadding = typeof rawContainerPadding === "number" ? `${rawContainerPadding}px` : rawContainerPadding;
@@ -1479,7 +1513,7 @@ var Column = (props) => {
1479
1513
  };
1480
1514
  Column.displayName = "Column";
1481
1515
  var Column_default = Column;
1482
- var DEFAULT_VALUES13 = BODY_DEFAULTS;
1516
+ var DEFAULT_VALUES14 = BODY_DEFAULTS;
1483
1517
  var MAX_PREVIEW_LENGTH = 150;
1484
1518
  var PADDING_CHARS = [
1485
1519
  "\xA0",
@@ -1525,8 +1559,8 @@ var Body = (props) => {
1525
1559
  const _config = { ...resolvedConfig, mode };
1526
1560
  _config.__ids = {};
1527
1561
  const values = mergeValues(
1528
- DEFAULT_VALUES13,
1529
- mapSemanticProps(semanticProps, DEFAULT_VALUES13, "Body")
1562
+ DEFAULT_VALUES14,
1563
+ mapSemanticProps(semanticProps, DEFAULT_VALUES14, "Body")
1530
1564
  );
1531
1565
  const valuesWithMeta = {
1532
1566
  ...values,
@@ -2272,6 +2306,6 @@ function registerTool(tool) {
2272
2306
  }
2273
2307
  var registerElementsTool = registerTool;
2274
2308
 
2275
- export { Body_default as Body, Button_default as Button, Column_default as Column, ColumnLayouts, DEFAULT_CONFIG, Divider_default as Divider, Document, Email, Heading_default as Heading, Html_default as Html, Image_default as Image, Menu_default as Menu, Page, Paragraph_default as Paragraph, Row_default as Row, Social_default as Social, Table_default as Table, UnlayerProvider, Video_default as Video, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
2309
+ export { Body_default as Body, Button_default as Button, Column_default as Column, ColumnLayouts, DEFAULT_CONFIG, Divider_default as Divider, Document, Email, Heading_default as Heading, Html_default as Html, Image_default as Image, Menu_default as Menu, Page, PageBreak_default as PageBreak, Paragraph_default as Paragraph, Row_default as Row, Social_default as Social, Table_default as Table, UnlayerProvider, Video_default as Video, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
2276
2310
  //# sourceMappingURL=index.js.map
2277
2311
  //# sourceMappingURL=index.js.map