@pdfme/ui 6.1.0 → 6.1.1-dev.4

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
@@ -9453,7 +9453,7 @@ function parseExpressionAt(input, pos, options) {
9453
9453
  }
9454
9454
  //#endregion
9455
9455
  //#region ../common/dist/index.js
9456
- var PDFME_VERSION = "6.1.0";
9456
+ var PDFME_VERSION = "6.1.1";
9457
9457
  var PT_TO_PX_RATIO = 1.333;
9458
9458
  var PT_TO_MM_RATIO = .3528;
9459
9459
  var MM_TO_PT_RATIO = 2.8346;
@@ -9560,7 +9560,18 @@ object$1({
9560
9560
  "schemas.date.locale": string$1(),
9561
9561
  "schemas.select.options": string$1(),
9562
9562
  "schemas.select.optionPlaceholder": string$1(),
9563
- "schemas.radioGroup.groupName": string$1()
9563
+ "schemas.radioGroup.groupName": string$1(),
9564
+ "schemas.list.listStyle": string$1(),
9565
+ "schemas.list.bullet": string$1(),
9566
+ "schemas.list.ordered": string$1(),
9567
+ "schemas.list.markerWidth": string$1(),
9568
+ "schemas.list.markerGap": string$1(),
9569
+ "schemas.list.indentSize": string$1(),
9570
+ "schemas.list.itemSpacing": string$1(),
9571
+ "schemas.list.addItem": string$1(),
9572
+ "schemas.list.removeItem": string$1(),
9573
+ "schemas.list.indentItem": string$1(),
9574
+ "schemas.list.outdentItem": string$1()
9564
9575
  });
9565
9576
  _enum([
9566
9577
  "viewer",
@@ -9590,6 +9601,10 @@ var Schema$1 = object$1({
9590
9601
  start: number$1(),
9591
9602
  end: number$1().optional()
9592
9603
  }).optional(),
9604
+ __itemRange: object$1({
9605
+ start: number$1(),
9606
+ end: number$1().optional()
9607
+ }).optional(),
9593
9608
  __isSplit: boolean$1().optional()
9594
9609
  }).passthrough();
9595
9610
  var SchemaForUIAdditionalInfo = object$1({ id: string$1() });
@@ -9858,7 +9873,7 @@ function normalizePageSchemas(pageSchemas, paddingTop) {
9858
9873
  schema: cloneDeep$1(schema),
9859
9874
  baseY: localY,
9860
9875
  height: schema.height,
9861
- dynamicHeights: [schema.height]
9876
+ dynamicLayout: { heights: [schema.height] }
9862
9877
  });
9863
9878
  orderMap.set(schema.name, index);
9864
9879
  });
@@ -9872,20 +9887,21 @@ function normalizePageSchemas(pageSchemas, paddingTop) {
9872
9887
  };
9873
9888
  }
9874
9889
  /**
9875
- * Place rows on pages, splitting across pages as needed.
9890
+ * Place height units on pages, splitting across pages as needed.
9876
9891
  * @returns The final global Y coordinate after placement
9877
9892
  */
9878
- function placeRowsOnPages(schema, dynamicHeights, startGlobalY, contentHeight, paddingTop, pages) {
9879
- let currentRowIndex = 0;
9893
+ function placeUnitsOnPages(schema, dynamicLayout, startGlobalY, contentHeight, paddingTop, pages) {
9894
+ const dynamicHeights = dynamicLayout.heights;
9895
+ let currentUnitIndex = 0;
9880
9896
  let currentPageIndex = Math.floor(startGlobalY / contentHeight);
9881
9897
  let currentYInPage = startGlobalY % contentHeight;
9882
9898
  if (currentYInPage < 0) currentYInPage = 0;
9883
9899
  let actualGlobalEndY = 0;
9884
9900
  const isSplittable = dynamicHeights.length > 1;
9885
- while (currentRowIndex < dynamicHeights.length) {
9901
+ while (currentUnitIndex < dynamicHeights.length) {
9886
9902
  while (pages.length <= currentPageIndex) pages.push([]);
9887
9903
  const spaceLeft = contentHeight - currentYInPage;
9888
- if (dynamicHeights[currentRowIndex] > spaceLeft + EPSILON) {
9904
+ if (dynamicHeights[currentUnitIndex] > spaceLeft + EPSILON) {
9889
9905
  if (!(Math.abs(spaceLeft - contentHeight) <= EPSILON)) {
9890
9906
  currentPageIndex++;
9891
9907
  currentYInPage = 0;
@@ -9893,40 +9909,41 @@ function placeRowsOnPages(schema, dynamicHeights, startGlobalY, contentHeight, p
9893
9909
  }
9894
9910
  }
9895
9911
  let chunkHeight = 0;
9896
- const startRowIndex = currentRowIndex;
9897
- while (currentRowIndex < dynamicHeights.length) {
9898
- const h = dynamicHeights[currentRowIndex];
9912
+ const startUnitIndex = currentUnitIndex;
9913
+ while (currentUnitIndex < dynamicHeights.length) {
9914
+ const h = dynamicHeights[currentUnitIndex];
9899
9915
  if (currentYInPage + chunkHeight + h <= contentHeight + EPSILON) {
9900
9916
  chunkHeight += h;
9901
- currentRowIndex++;
9917
+ currentUnitIndex++;
9902
9918
  } else break;
9903
9919
  }
9904
9920
  const isAtPageTop = currentYInPage <= EPSILON;
9905
- if (isSplittable && startRowIndex === 0 && currentRowIndex === 1 && dynamicHeights.length > 1 && !isAtPageTop) {
9906
- currentRowIndex = 0;
9921
+ if (dynamicLayout.avoidFirstUnitOnly && isSplittable && startUnitIndex === 0 && currentUnitIndex === 1 && dynamicHeights.length > 1 && !isAtPageTop) {
9922
+ currentUnitIndex = 0;
9907
9923
  currentPageIndex++;
9908
9924
  currentYInPage = 0;
9909
9925
  continue;
9910
9926
  }
9911
- if (currentRowIndex === startRowIndex) {
9912
- chunkHeight += dynamicHeights[currentRowIndex];
9913
- currentRowIndex++;
9927
+ if (currentUnitIndex === startUnitIndex) {
9928
+ chunkHeight += dynamicHeights[currentUnitIndex];
9929
+ currentUnitIndex++;
9914
9930
  }
9931
+ const patch = dynamicLayout.patchSplitSchema?.({
9932
+ schema,
9933
+ start: startUnitIndex,
9934
+ end: currentUnitIndex,
9935
+ isSplit: startUnitIndex > 0,
9936
+ chunkHeight
9937
+ }) ?? {};
9915
9938
  const newSchema = {
9916
9939
  ...schema,
9940
+ ...patch,
9917
9941
  height: chunkHeight,
9918
9942
  position: {
9919
9943
  ...schema.position,
9920
9944
  y: currentYInPage + paddingTop
9921
9945
  }
9922
9946
  };
9923
- if (isSplittable) {
9924
- newSchema.__bodyRange = {
9925
- start: startRowIndex === 0 ? 0 : startRowIndex - 1,
9926
- end: currentRowIndex - 1
9927
- };
9928
- newSchema.__isSplit = startRowIndex > 0;
9929
- }
9930
9947
  pages[currentPageIndex].push(newSchema);
9931
9948
  currentYInPage += chunkHeight;
9932
9949
  if (currentYInPage >= contentHeight - EPSILON) {
@@ -9957,12 +9974,19 @@ function processDynamicPage(items, orderMap, contentHeight, paddingTop) {
9957
9974
  let totalYOffset = 0;
9958
9975
  for (const item of items) {
9959
9976
  const currentGlobalStartY = item.baseY + totalYOffset;
9960
- totalYOffset = placeRowsOnPages(item.schema, item.dynamicHeights, currentGlobalStartY, contentHeight, paddingTop, pages) - (item.baseY + item.height);
9977
+ totalYOffset = placeUnitsOnPages(item.schema, item.dynamicLayout, currentGlobalStartY, contentHeight, paddingTop, pages) - (item.baseY + item.height);
9961
9978
  }
9962
9979
  sortPagesByOrder(pages, orderMap);
9963
9980
  removeTrailingEmptyPages(pages);
9964
9981
  return pages;
9965
9982
  }
9983
+ var normalizeDynamicLayoutResult = (result) => {
9984
+ const dynamicLayout = Array.isArray(result) ? { heights: result } : result;
9985
+ return {
9986
+ ...dynamicLayout,
9987
+ heights: dynamicLayout.heights.length === 0 ? [0] : dynamicLayout.heights
9988
+ };
9989
+ };
9966
9990
  /**
9967
9991
  * Process a template containing tables with dynamic heights
9968
9992
  * and generate a new template with proper page breaks.
@@ -9994,9 +10018,9 @@ var getDynamicTemplate = async (arg) => {
9994
10018
  basePdf,
9995
10019
  options,
9996
10020
  _cache
9997
- }).then((heights) => heights.length === 0 ? [0] : heights);
10021
+ }).then(normalizeDynamicLayoutResult);
9998
10022
  }));
9999
- for (let j = 0; j < chunkResults.length; j++) items[i + j].dynamicHeights = chunkResults[j];
10023
+ for (let j = 0; j < chunkResults.length; j++) items[i + j].dynamicLayout = chunkResults[j];
10000
10024
  }
10001
10025
  const processedPages = processDynamicPage(items, orderMap, contentHeight, paddingTop);
10002
10026
  resultPages.push(...processedPages);
@@ -81492,7 +81516,18 @@ var dictionaries = {
81492
81516
  "schemas.date.locale": "Locale",
81493
81517
  "schemas.select.options": "Options",
81494
81518
  "schemas.select.optionPlaceholder": "Enter an option",
81495
- "schemas.radioGroup.groupName": "Group Name"
81519
+ "schemas.radioGroup.groupName": "Group Name",
81520
+ "schemas.list.listStyle": "List Style",
81521
+ "schemas.list.bullet": "Bullet",
81522
+ "schemas.list.ordered": "Ordered",
81523
+ "schemas.list.markerWidth": "Marker Width",
81524
+ "schemas.list.markerGap": "Marker Gap",
81525
+ "schemas.list.indentSize": "Indent Size",
81526
+ "schemas.list.itemSpacing": "Item Spacing",
81527
+ "schemas.list.addItem": "Add item",
81528
+ "schemas.list.removeItem": "Remove item",
81529
+ "schemas.list.indentItem": "Indent item",
81530
+ "schemas.list.outdentItem": "Outdent item"
81496
81531
  },
81497
81532
  zh: {
81498
81533
  cancel: "取消",
@@ -81581,7 +81616,18 @@ var dictionaries = {
81581
81616
  "schemas.date.locale": " 语言环境",
81582
81617
  "schemas.select.options": "选项",
81583
81618
  "schemas.select.optionPlaceholder": "请输入选项",
81584
- "schemas.radioGroup.groupName": "组名"
81619
+ "schemas.radioGroup.groupName": "组名",
81620
+ "schemas.list.listStyle": "列表样式",
81621
+ "schemas.list.bullet": "项目符号",
81622
+ "schemas.list.ordered": "编号",
81623
+ "schemas.list.markerWidth": "标记宽度",
81624
+ "schemas.list.markerGap": "标记间距",
81625
+ "schemas.list.indentSize": "缩进大小",
81626
+ "schemas.list.itemSpacing": "项目间距",
81627
+ "schemas.list.addItem": "添加项目",
81628
+ "schemas.list.removeItem": "删除项目",
81629
+ "schemas.list.indentItem": "增加缩进",
81630
+ "schemas.list.outdentItem": "减少缩进"
81585
81631
  },
81586
81632
  ja: {
81587
81633
  cancel: "キャンセル",
@@ -81670,7 +81716,18 @@ var dictionaries = {
81670
81716
  "schemas.date.locale": "ロケール",
81671
81717
  "schemas.select.options": "オプション",
81672
81718
  "schemas.select.optionPlaceholder": "オプションを入力してください",
81673
- "schemas.radioGroup.groupName": "グループ名"
81719
+ "schemas.radioGroup.groupName": "グループ名",
81720
+ "schemas.list.listStyle": "リストスタイル",
81721
+ "schemas.list.bullet": "箇条書き",
81722
+ "schemas.list.ordered": "番号付き",
81723
+ "schemas.list.markerWidth": "マーカー幅",
81724
+ "schemas.list.markerGap": "マーカー間隔",
81725
+ "schemas.list.indentSize": "インデント幅",
81726
+ "schemas.list.itemSpacing": "項目間隔",
81727
+ "schemas.list.addItem": "項目を追加",
81728
+ "schemas.list.removeItem": "項目を削除",
81729
+ "schemas.list.indentItem": "インデント",
81730
+ "schemas.list.outdentItem": "インデント解除"
81674
81731
  },
81675
81732
  ko: {
81676
81733
  cancel: "취소",
@@ -81759,7 +81816,18 @@ var dictionaries = {
81759
81816
  "schemas.date.locale": " 장소",
81760
81817
  "schemas.select.options": "옵션",
81761
81818
  "schemas.select.optionPlaceholder": "옵션을 입력하세요",
81762
- "schemas.radioGroup.groupName": "그룹 이름"
81819
+ "schemas.radioGroup.groupName": "그룹 이름",
81820
+ "schemas.list.listStyle": "목록 스타일",
81821
+ "schemas.list.bullet": "글머리 기호",
81822
+ "schemas.list.ordered": "번호 매기기",
81823
+ "schemas.list.markerWidth": "마커 너비",
81824
+ "schemas.list.markerGap": "마커 간격",
81825
+ "schemas.list.indentSize": "들여쓰기 크기",
81826
+ "schemas.list.itemSpacing": "항목 간격",
81827
+ "schemas.list.addItem": "항목 추가",
81828
+ "schemas.list.removeItem": "항목 삭제",
81829
+ "schemas.list.indentItem": "들여쓰기",
81830
+ "schemas.list.outdentItem": "내어쓰기"
81763
81831
  },
81764
81832
  ar: {
81765
81833
  cancel: "إلغاء",
@@ -81848,7 +81916,18 @@ var dictionaries = {
81848
81916
  "schemas.date.locale": "لغة",
81849
81917
  "schemas.select.options": "خيارات",
81850
81918
  "schemas.select.optionPlaceholder": "أدخل خيارًا",
81851
- "schemas.radioGroup.groupName": "اسم المجموعة"
81919
+ "schemas.radioGroup.groupName": "اسم المجموعة",
81920
+ "schemas.list.listStyle": "نمط القائمة",
81921
+ "schemas.list.bullet": "نقاط",
81922
+ "schemas.list.ordered": "مرقمة",
81923
+ "schemas.list.markerWidth": "عرض العلامة",
81924
+ "schemas.list.markerGap": "مسافة العلامة",
81925
+ "schemas.list.indentSize": "حجم المسافة البادئة",
81926
+ "schemas.list.itemSpacing": "تباعد العناصر",
81927
+ "schemas.list.addItem": "إضافة عنصر",
81928
+ "schemas.list.removeItem": "حذف عنصر",
81929
+ "schemas.list.indentItem": "زيادة المسافة البادئة",
81930
+ "schemas.list.outdentItem": "تقليل المسافة البادئة"
81852
81931
  },
81853
81932
  th: {
81854
81933
  cancel: "ยกเลิก",
@@ -81937,7 +82016,18 @@ var dictionaries = {
81937
82016
  "schemas.date.locale": "สถาน",
81938
82017
  "schemas.select.options": "ตัวเลือก",
81939
82018
  "schemas.select.optionPlaceholder": "กรอกตัวเลือก",
81940
- "schemas.radioGroup.groupName": "ชื่อกลุ่ม"
82019
+ "schemas.radioGroup.groupName": "ชื่อกลุ่ม",
82020
+ "schemas.list.listStyle": "รูปแบบรายการ",
82021
+ "schemas.list.bullet": "สัญลักษณ์หัวข้อ",
82022
+ "schemas.list.ordered": "ลำดับเลข",
82023
+ "schemas.list.markerWidth": "ความกว้างเครื่องหมาย",
82024
+ "schemas.list.markerGap": "ระยะห่างเครื่องหมาย",
82025
+ "schemas.list.indentSize": "ขนาดย่อหน้า",
82026
+ "schemas.list.itemSpacing": "ระยะห่างรายการ",
82027
+ "schemas.list.addItem": "เพิ่มรายการ",
82028
+ "schemas.list.removeItem": "ลบรายการ",
82029
+ "schemas.list.indentItem": "เพิ่มย่อหน้า",
82030
+ "schemas.list.outdentItem": "ลดย่อหน้า"
81941
82031
  },
81942
82032
  it: {
81943
82033
  cancel: "Annulla",
@@ -82026,7 +82116,18 @@ var dictionaries = {
82026
82116
  "schemas.date.locale": "Locale",
82027
82117
  "schemas.select.options": "Opzioni",
82028
82118
  "schemas.select.optionPlaceholder": "Inserisci un'opzione",
82029
- "schemas.radioGroup.groupName": "Nome del Gruppo"
82119
+ "schemas.radioGroup.groupName": "Nome del Gruppo",
82120
+ "schemas.list.listStyle": "Stile elenco",
82121
+ "schemas.list.bullet": "Puntato",
82122
+ "schemas.list.ordered": "Numerato",
82123
+ "schemas.list.markerWidth": "Larghezza indicatore",
82124
+ "schemas.list.markerGap": "Spazio indicatore",
82125
+ "schemas.list.indentSize": "Dimensione rientro",
82126
+ "schemas.list.itemSpacing": "Spaziatura elementi",
82127
+ "schemas.list.addItem": "Aggiungi elemento",
82128
+ "schemas.list.removeItem": "Rimuovi elemento",
82129
+ "schemas.list.indentItem": "Aumenta rientro",
82130
+ "schemas.list.outdentItem": "Riduci rientro"
82030
82131
  },
82031
82132
  pl: {
82032
82133
  cancel: "Anuluj",
@@ -82115,7 +82216,18 @@ var dictionaries = {
82115
82216
  "schemas.date.locale": "Widownia",
82116
82217
  "schemas.select.options": "Opcje",
82117
82218
  "schemas.select.optionPlaceholder": "Wpisz opcję",
82118
- "schemas.radioGroup.groupName": "Nazwa grupy"
82219
+ "schemas.radioGroup.groupName": "Nazwa grupy",
82220
+ "schemas.list.listStyle": "Styl listy",
82221
+ "schemas.list.bullet": "Punktowana",
82222
+ "schemas.list.ordered": "Numerowana",
82223
+ "schemas.list.markerWidth": "Szerokość znacznika",
82224
+ "schemas.list.markerGap": "Odstęp znacznika",
82225
+ "schemas.list.indentSize": "Rozmiar wcięcia",
82226
+ "schemas.list.itemSpacing": "Odstęp elementów",
82227
+ "schemas.list.addItem": "Dodaj element",
82228
+ "schemas.list.removeItem": "Usuń element",
82229
+ "schemas.list.indentItem": "Zwiększ wcięcie",
82230
+ "schemas.list.outdentItem": "Zmniejsz wcięcie"
82119
82231
  },
82120
82232
  de: {
82121
82233
  cancel: "Abbrechen",
@@ -82204,7 +82316,18 @@ var dictionaries = {
82204
82316
  "schemas.date.locale": "Gebietsschema",
82205
82317
  "schemas.select.options": "Optionen",
82206
82318
  "schemas.select.optionPlaceholder": "Geben Sie eine Option ein",
82207
- "schemas.radioGroup.groupName": "Gruppenname"
82319
+ "schemas.radioGroup.groupName": "Gruppenname",
82320
+ "schemas.list.listStyle": "Listenstil",
82321
+ "schemas.list.bullet": "Aufzählung",
82322
+ "schemas.list.ordered": "Nummeriert",
82323
+ "schemas.list.markerWidth": "Markerbreite",
82324
+ "schemas.list.markerGap": "Markerabstand",
82325
+ "schemas.list.indentSize": "Einzugsgröße",
82326
+ "schemas.list.itemSpacing": "Elementabstand",
82327
+ "schemas.list.addItem": "Element hinzufügen",
82328
+ "schemas.list.removeItem": "Element entfernen",
82329
+ "schemas.list.indentItem": "Einzug erhöhen",
82330
+ "schemas.list.outdentItem": "Einzug verringern"
82208
82331
  },
82209
82332
  es: {
82210
82333
  cancel: "Cancelar",
@@ -82293,7 +82416,18 @@ var dictionaries = {
82293
82416
  "schemas.date.locale": "Lugar",
82294
82417
  "schemas.select.options": "Opciones",
82295
82418
  "schemas.select.optionPlaceholder": "Ingrese una opción",
82296
- "schemas.radioGroup.groupName": "Nombre del grupo"
82419
+ "schemas.radioGroup.groupName": "Nombre del grupo",
82420
+ "schemas.list.listStyle": "Estilo de lista",
82421
+ "schemas.list.bullet": "Viñetas",
82422
+ "schemas.list.ordered": "Numerada",
82423
+ "schemas.list.markerWidth": "Ancho del marcador",
82424
+ "schemas.list.markerGap": "Espacio del marcador",
82425
+ "schemas.list.indentSize": "Tamaño de sangría",
82426
+ "schemas.list.itemSpacing": "Espaciado de elementos",
82427
+ "schemas.list.addItem": "Agregar elemento",
82428
+ "schemas.list.removeItem": "Eliminar elemento",
82429
+ "schemas.list.indentItem": "Aumentar sangría",
82430
+ "schemas.list.outdentItem": "Reducir sangría"
82297
82431
  },
82298
82432
  fr: {
82299
82433
  cancel: "Annuler",
@@ -82382,7 +82516,18 @@ var dictionaries = {
82382
82516
  "schemas.date.locale": "Lieu",
82383
82517
  "schemas.select.options": "Options",
82384
82518
  "schemas.select.optionPlaceholder": "Entrez une option",
82385
- "schemas.radioGroup.groupName": "Nom du groupe"
82519
+ "schemas.radioGroup.groupName": "Nom du groupe",
82520
+ "schemas.list.listStyle": "Style de liste",
82521
+ "schemas.list.bullet": "Puces",
82522
+ "schemas.list.ordered": "Numérotée",
82523
+ "schemas.list.markerWidth": "Largeur du marqueur",
82524
+ "schemas.list.markerGap": "Espacement du marqueur",
82525
+ "schemas.list.indentSize": "Taille du retrait",
82526
+ "schemas.list.itemSpacing": "Espacement des éléments",
82527
+ "schemas.list.addItem": "Ajouter un élément",
82528
+ "schemas.list.removeItem": "Supprimer un élément",
82529
+ "schemas.list.indentItem": "Augmenter le retrait",
82530
+ "schemas.list.outdentItem": "Réduire le retrait"
82386
82531
  }
82387
82532
  };
82388
82533
  var getDict = (lang) => dictionaries[lang] || dictionaries["en"];
@@ -98333,7 +98478,7 @@ $d636bc798e7178db$export$36b2f24e97d43be($21ee218f84ac7f32$export$2e2bcd8739ae03
98333
98478
  $d636bc798e7178db$export$36b2f24e97d43be($cd5853a56c68fec7$export$2e2bcd8739ae039);
98334
98479
  $d636bc798e7178db$export$36b2f24e97d43be($05f49f930186144e$export$2e2bcd8739ae039);
98335
98480
  //#endregion
98336
- //#region ../schemas/dist/dynamicTemplate-Dsrw11aL.js
98481
+ //#region ../schemas/dist/helper-6FilIoVM.js
98337
98482
  var ALIGN_LEFT = "left";
98338
98483
  var ALIGN_CENTER = "center";
98339
98484
  var ALIGN_RIGHT = "right";
@@ -98453,10 +98598,27 @@ var heightOfFontAtSize = (fontKitFont, fontSize) => {
98453
98598
  var calculateCharacterSpacing = (textContent, textCharacterSpacing) => {
98454
98599
  return (textContent.length - 1) * textCharacterSpacing;
98455
98600
  };
98601
+ var TEXT_WIDTH_CACHE_LIMIT = 5e3;
98602
+ var textWidthCache = /* @__PURE__ */ new WeakMap();
98603
+ var getTextWidthCache = (fontKitFont) => {
98604
+ let cache = textWidthCache.get(fontKitFont);
98605
+ if (!cache) {
98606
+ cache = /* @__PURE__ */ new Map();
98607
+ textWidthCache.set(fontKitFont, cache);
98608
+ }
98609
+ return cache;
98610
+ };
98456
98611
  var widthOfTextAtSize = (text, fontKitFont, fontSize, characterSpacing) => {
98612
+ const cache = getTextWidthCache(fontKitFont);
98613
+ const cacheKey = `${fontSize}\0${characterSpacing}\0${text}`;
98614
+ const cachedWidth = cache.get(cacheKey);
98615
+ if (cachedWidth !== void 0) return cachedWidth;
98457
98616
  const { glyphs } = fontKitFont.layout(text);
98458
98617
  const scale = 1e3 / fontKitFont.unitsPerEm;
98459
- return glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) * (fontSize / 1e3) + calculateCharacterSpacing(text, characterSpacing);
98618
+ const width = glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) * (fontSize / 1e3) + calculateCharacterSpacing(text, characterSpacing);
98619
+ if (cache.size >= TEXT_WIDTH_CACHE_LIMIT) cache.clear();
98620
+ cache.set(cacheKey, width);
98621
+ return width;
98460
98622
  };
98461
98623
  var getFallbackFont = (font) => {
98462
98624
  return font[getFallbackFontName(font)];
@@ -98576,10 +98738,15 @@ var splitTextToSize = (arg) => {
98576
98738
  return lines;
98577
98739
  };
98578
98740
  var isFirefox = () => navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
98741
+ var wordSegmenter;
98742
+ var getWordSegmenter = () => {
98743
+ wordSegmenter ?? (wordSegmenter = new Intl.Segmenter(void 0, { granularity: "word" }));
98744
+ return wordSegmenter;
98745
+ };
98579
98746
  var getSplittedLinesBySegmenter = (line, calcValues) => {
98580
98747
  if (line.trim() === "") return [""];
98581
98748
  const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;
98582
- const iterator = new Intl.Segmenter(void 0, { granularity: "word" }).segment(line.trimEnd())[Symbol.iterator]();
98749
+ const iterator = getWordSegmenter().segment(line.trimEnd())[Symbol.iterator]();
98583
98750
  let lines = [];
98584
98751
  let lineCounter = 0;
98585
98752
  let currentTextSize = 0;
@@ -98681,6 +98848,8 @@ var filterEndJP = (lines) => {
98681
98848
  return [...filtered.slice(0, -1), combinedItem];
98682
98849
  } else return filtered;
98683
98850
  };
98851
+ //#endregion
98852
+ //#region ../schemas/dist/dynamicTemplate-DslOH4FZ.js
98684
98853
  function _typeof$18(o) {
98685
98854
  "@babel/helpers - typeof";
98686
98855
  return _typeof$18 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -99226,6 +99395,19 @@ var getDynamicHeightsForTable = async (value, args) => {
99226
99395
  }
99227
99396
  return result;
99228
99397
  };
99398
+ var getDynamicLayoutForTable = async (value, args) => {
99399
+ return {
99400
+ heights: await getDynamicHeightsForTable(value, args),
99401
+ avoidFirstUnitOnly: true,
99402
+ patchSplitSchema: ({ start, end, isSplit }) => ({
99403
+ __bodyRange: {
99404
+ start: start === 0 ? 0 : start - 1,
99405
+ end: end - 1
99406
+ },
99407
+ __isSplit: isSplit
99408
+ })
99409
+ };
99410
+ };
99229
99411
  //#endregion
99230
99412
  //#region ../schemas/dist/utils.js
99231
99413
  var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
@@ -99517,7 +99699,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
99517
99699
  y2: "20"
99518
99700
  }]];
99519
99701
  //#endregion
99520
- //#region ../schemas/dist/builtins-C0BvXHWr.js
99702
+ //#region ../schemas/dist/builtins-CFqn6U5J.js
99521
99703
  var MARKDOWN_ESCAPABLE_CHARS = new Set([
99522
99704
  "\\",
99523
99705
  "*",
@@ -99935,11 +100117,16 @@ var calculateDynamicRichTextFontSize = async (arg) => {
99935
100117
  var getSyntheticBoldWidth = (run, fontSize) => run.syntheticBold ? fontSize * SYNTHETIC_BOLD_OFFSET_RATIO * 2 : 0;
99936
100118
  var getSyntheticItalicWidth = (run, fontSize) => run.syntheticItalic ? heightOfFontAtSize(run.fontKitFont, fontSize) * Math.tan(12 * Math.PI / 180) : 0;
99937
100119
  var getRunWidth = (run, fontSize, characterSpacing) => widthOfTextAtSize(run.text, run.fontKitFont, fontSize, characterSpacing) + getSyntheticBoldWidth(run, fontSize) + getSyntheticItalicWidth(run, fontSize);
99938
- var getPdfFont = (run, pdfFontObj) => {
100120
+ var getPdfFontFromObj = (run, pdfFontObj) => {
99939
100121
  const pdfFont = pdfFontObj[run.fontName];
99940
100122
  if (!pdfFont) throw new Error(`[@pdfme/schemas] Missing embedded font "${run.fontName}".`);
99941
100123
  return pdfFont;
99942
100124
  };
100125
+ var embedFontsForRuns = async (runs, embedPdfFont) => {
100126
+ const fontNames = Array.from(new Set(runs.map((run) => run.fontName)));
100127
+ const pdfFonts = await Promise.all(fontNames.map(async (fontName) => [fontName, await embedPdfFont(fontName)]));
100128
+ return Object.fromEntries(pdfFonts);
100129
+ };
99943
100130
  var drawDecorationLine = (arg) => {
99944
100131
  const { page, x, y, width, rotate, pivotPoint, fontSize, color, opacity } = arg;
99945
100132
  if (width <= 0) return;
@@ -100020,7 +100207,7 @@ var drawRun = (arg) => {
100020
100207
  }
100021
100208
  };
100022
100209
  var renderInlineMarkdownText = async (arg) => {
100023
- const { value, schema, font, pdfFontObj, fontKitFont, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, width, height, pageHeight, pivotPoint, rotate, opacity } = arg;
100210
+ const { value, schema, font, embedPdfFont, fontKitFont, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, width, height, pageHeight, pivotPoint, rotate, opacity } = arg;
100024
100211
  const lines = layoutRichTextLines({
100025
100212
  runs: await resolveRichTextRuns({
100026
100213
  runs: parseInlineMarkdown(value),
@@ -100032,6 +100219,7 @@ var renderInlineMarkdownText = async (arg) => {
100032
100219
  characterSpacing,
100033
100220
  boxWidthInPt: width
100034
100221
  });
100222
+ const pdfFontObj = await embedFontsForRuns(lines.flatMap((line) => line.runs), embedPdfFont);
100035
100223
  const firstLineTextHeight = heightOfFontAtSize(fontKitFont, fontSize);
100036
100224
  const descent = getFontDescentInPt(fontKitFont, fontSize);
100037
100225
  const halfLineHeightAdjustment = lineHeight === 0 ? 0 : (lineHeight - 1) * fontSize / 2;
@@ -100089,7 +100277,7 @@ var renderInlineMarkdownText = async (arg) => {
100089
100277
  page,
100090
100278
  pdfLib,
100091
100279
  run,
100092
- pdfFont: getPdfFont(run, pdfFontObj),
100280
+ pdfFont: getPdfFontFromObj(run, pdfFontObj),
100093
100281
  x: currentX,
100094
100282
  y: yLine,
100095
100283
  rotate,
@@ -100106,17 +100294,29 @@ var renderInlineMarkdownText = async (arg) => {
100106
100294
  }, xLine);
100107
100295
  });
100108
100296
  };
100109
- var embedAndGetFontObj = async (arg) => {
100110
- const { pdfDoc, font, _cache } = arg;
100111
- if (_cache.has(pdfDoc)) return _cache.get(pdfDoc);
100112
- const fontValues = await Promise.all(Object.values(font).map(async (v) => {
100113
- let fontData = v.data;
100297
+ var PDF_FONT_CACHE_KEY = "text-pdf-font-cache";
100298
+ var getPdfFontCache = (_cache) => {
100299
+ let pdfFontCache = _cache.get(PDF_FONT_CACHE_KEY);
100300
+ if (!pdfFontCache) {
100301
+ pdfFontCache = {};
100302
+ _cache.set(PDF_FONT_CACHE_KEY, pdfFontCache);
100303
+ }
100304
+ return pdfFontCache;
100305
+ };
100306
+ var embedAndGetFont = (arg) => {
100307
+ const { pdfDoc, font, fontName, _cache } = arg;
100308
+ const pdfFontCache = getPdfFontCache(_cache);
100309
+ const cachedFont = pdfFontCache[fontName];
100310
+ if (cachedFont) return cachedFont;
100311
+ const fontValue = font[fontName];
100312
+ if (!fontValue) return Promise.reject(/* @__PURE__ */ new Error(`[@pdfme/schemas] Font "${fontName}" is not found.`));
100313
+ const pdfFontPromise = (async () => {
100314
+ let fontData = fontValue.data;
100114
100315
  if (typeof fontData === "string" && fontData.startsWith("http")) fontData = await fetchRemoteFontData(fontData);
100115
- return pdfDoc.embedFont(fontData, { subset: typeof v.subset === "undefined" ? true : v.subset });
100116
- }));
100117
- const fontObj = Object.keys(font).reduce((acc, cur, i) => Object.assign(acc, { [cur]: fontValues[i] }), {});
100118
- _cache.set(pdfDoc, fontObj);
100119
- return fontObj;
100316
+ return pdfDoc.embedFont(fontData, { subset: typeof fontValue.subset === "undefined" ? true : fontValue.subset });
100317
+ })();
100318
+ pdfFontCache[fontName] = pdfFontPromise;
100319
+ return pdfFontPromise;
100120
100320
  };
100121
100321
  var getFontProp = ({ value, fontKitFont, schema, colorType, fontSize: resolvedFontSize }) => {
100122
100322
  const fontSize = resolvedFontSize ?? (schema.dynamicFontSize ? calculateDynamicFontSize({
@@ -100134,16 +100334,24 @@ var getFontProp = ({ value, fontKitFont, schema, colorType, fontSize: resolvedFo
100134
100334
  color
100135
100335
  };
100136
100336
  };
100337
+ var graphemeSegmenter;
100338
+ var getGraphemeSegmenter = () => {
100339
+ graphemeSegmenter ?? (graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" }));
100340
+ return graphemeSegmenter;
100341
+ };
100137
100342
  var pdfRender = async (arg) => {
100138
100343
  const { value, pdfDoc, pdfLib, page, options, schema, _cache } = arg;
100139
100344
  if (!value) return;
100140
100345
  const { font = getDefaultFont(), colorType } = options;
100141
- const [pdfFontObj, fontKitFont] = await Promise.all([embedAndGetFontObj({
100346
+ const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);
100347
+ const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);
100348
+ const pdfFontValuePromise = enableInlineMarkdown ? void 0 : embedAndGetFont({
100142
100349
  pdfDoc,
100143
100350
  font,
100351
+ fontName,
100144
100352
  _cache
100145
- }), getFontKitFont(schema.fontName, font, _cache)]);
100146
- const enableInlineMarkdown = isInlineMarkdownTextSchema(schema);
100353
+ });
100354
+ const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
100147
100355
  const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = getFontProp({
100148
100356
  value: enableInlineMarkdown ? stripInlineMarkdown(value) : value,
100149
100357
  fontKitFont,
@@ -100156,8 +100364,6 @@ var pdfRender = async (arg) => {
100156
100364
  _cache
100157
100365
  }) : void 0
100158
100366
  });
100159
- const fontName = schema.fontName ? schema.fontName : getFallbackFontName(font);
100160
- const pdfFontValue = pdfFontObj && pdfFontObj[fontName];
100161
100367
  const pageHeight = page.getHeight();
100162
100368
  const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
100163
100369
  schema,
@@ -100197,7 +100403,12 @@ var pdfRender = async (arg) => {
100197
100403
  value,
100198
100404
  schema,
100199
100405
  font,
100200
- pdfFontObj,
100406
+ embedPdfFont: (fontName) => embedAndGetFont({
100407
+ pdfDoc,
100408
+ font,
100409
+ fontName,
100410
+ _cache
100411
+ }),
100201
100412
  fontKitFont,
100202
100413
  page,
100203
100414
  pdfLib,
@@ -100219,6 +100430,8 @@ var pdfRender = async (arg) => {
100219
100430
  });
100220
100431
  return;
100221
100432
  }
100433
+ if (!pdfFontValuePromise) throw new Error("[@pdfme/schemas] Failed to prepare PDF font for text rendering.");
100434
+ const pdfFontValue = await pdfFontValuePromise;
100222
100435
  const firstLineTextHeight = heightOfFontAtSize(fontKitFont, fontSize);
100223
100436
  const descent = getFontDescentInPt(fontKitFont, fontSize);
100224
100437
  const halfLineHeightAdjustment = lineHeight === 0 ? 0 : (lineHeight - 1) * fontSize / 2;
@@ -100229,6 +100442,8 @@ var pdfRender = async (arg) => {
100229
100442
  fontKitFont,
100230
100443
  boxWidthInPt: width
100231
100444
  });
100445
+ const needsTextWidth = alignment !== "left" || Boolean(schema.strikethrough || schema.underline);
100446
+ const needsTextHeight = Boolean(schema.strikethrough || schema.underline);
100232
100447
  let yOffset = 0;
100233
100448
  if (verticalAlignment === "top") yOffset = firstLineTextHeight + halfLineHeightAdjustment;
100234
100449
  else {
@@ -100236,11 +100451,10 @@ var pdfRender = async (arg) => {
100236
100451
  if (verticalAlignment === "bottom") yOffset = height - otherLinesHeight + descent - halfLineHeightAdjustment;
100237
100452
  else if (verticalAlignment === "middle") yOffset = (height - otherLinesHeight - firstLineTextHeight + descent) / 2 + firstLineTextHeight;
100238
100453
  }
100239
- const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
100240
100454
  lines.forEach((line, rowIndex) => {
100241
100455
  const trimmed = line.replace("\n", "");
100242
- const textWidth = widthOfTextAtSize(trimmed, fontKitFont, fontSize, characterSpacing);
100243
- const textHeight = heightOfFontAtSize(fontKitFont, fontSize);
100456
+ const textWidth = needsTextWidth ? widthOfTextAtSize(trimmed, fontKitFont, fontSize, characterSpacing) : 0;
100457
+ const textHeight = needsTextHeight ? heightOfFontAtSize(fontKitFont, fontSize) : 0;
100244
100458
  const rowYOffset = lineHeight * fontSize * rowIndex;
100245
100459
  if (line === "") line = "\r\n";
100246
100460
  let xLine = x;
@@ -100291,7 +100505,7 @@ var pdfRender = async (arg) => {
100291
100505
  }
100292
100506
  let spacing = characterSpacing;
100293
100507
  if (alignment === "justify" && line.slice(-1) !== "\n") {
100294
- const iterator = segmenter.segment(trimmed)[Symbol.iterator]();
100508
+ const iterator = getGraphemeSegmenter().segment(trimmed)[Symbol.iterator]();
100295
100509
  const len = Array.from(iterator).length;
100296
100510
  spacing += (width - textWidth) / len;
100297
100511
  }
@@ -101213,6 +101427,20 @@ var changeSchemas = (args) => {
101213
101427
  return acc;
101214
101428
  }, cloneDeep$1(schemas)));
101215
101429
  };
101430
+ var getDynamicHeightReflowChanges = (args) => {
101431
+ const { schemas, schema, height } = args;
101432
+ if (schema.type !== "list") return [];
101433
+ const nextHeight = Number(height);
101434
+ if (!Number.isFinite(nextHeight)) return [];
101435
+ const delta = nextHeight - schema.height;
101436
+ if (delta === 0) return [];
101437
+ const baseBottom = schema.position.y + schema.height;
101438
+ return schemas.filter((s) => s.id !== schema.id && s.position.y >= baseBottom).map((s) => ({
101439
+ key: "position.y",
101440
+ value: round$2(s.position.y + delta, 2),
101441
+ schemaId: s.id
101442
+ }));
101443
+ };
101216
101444
  var useMaxZoom = () => {
101217
101445
  const options = (0, import_react$9.useContext)(OptionsContext);
101218
101446
  return options.maxZoom ? options.maxZoom / 100 : 2;
@@ -234866,6 +235094,105 @@ var Designer = class extends BaseUIClass {
234866
235094
  }
234867
235095
  };
234868
235096
  //#endregion
235097
+ //#region ../schemas/dist/lists-BmAAx0lx.js
235098
+ var normalizeListItems = (value) => {
235099
+ if (Array.isArray(value)) return value.map((item) => String(item));
235100
+ if (typeof value !== "string") return value == null ? [] : [String(value)];
235101
+ const trimmed = value.trim();
235102
+ if (!trimmed) return [];
235103
+ try {
235104
+ const parsed = JSON.parse(trimmed);
235105
+ if (Array.isArray(parsed)) return parsed.map((item) => String(item));
235106
+ } catch {}
235107
+ return value.split(/\r\n|\r|\n/g);
235108
+ };
235109
+ var parseListItem = (value) => {
235110
+ const indent = value.match(/^\t+/)?.[0].length ?? 0;
235111
+ return {
235112
+ level: Math.min(indent, 8),
235113
+ text: value.slice(indent)
235114
+ };
235115
+ };
235116
+ var getListMarkers = (schema, items) => {
235117
+ if ((schema.listStyle ?? "bullet") !== "ordered") return items.map(() => "•");
235118
+ const counters = Array.from({ length: 9 }, () => 0);
235119
+ return items.map((rawItem) => {
235120
+ const { level } = parseListItem(rawItem);
235121
+ counters[level] += 1;
235122
+ counters.fill(0, level + 1);
235123
+ return `${counters[level]}.`;
235124
+ });
235125
+ };
235126
+ var calculateListLayout = async (arg) => {
235127
+ const { schema, items, markerItems, startIndex, options, _cache } = arg;
235128
+ const markerWidth = schema.markerWidth ?? 6;
235129
+ const markerGap = schema.markerGap ?? 2;
235130
+ const indentSize = schema.indentSize ?? 6;
235131
+ const font = options.font || getDefaultFont();
235132
+ const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
235133
+ const fontSize = schema.fontSize ?? 13;
235134
+ const lineHeight = schema.lineHeight ?? 1;
235135
+ const characterSpacing = schema.characterSpacing ?? 0;
235136
+ const itemSpacing = schema.itemSpacing ?? 1;
235137
+ const lineHeightMm = pt2mm(fontSize * lineHeight);
235138
+ const markers = markerItems ? getListMarkers(schema, markerItems).slice(startIndex, startIndex + items.length) : getListMarkers(schema, items);
235139
+ const layoutItems = items.map((rawItem, index) => {
235140
+ const item = parseListItem(rawItem);
235141
+ const markerX = item.level * indentSize;
235142
+ const bodyX = markerX + markerWidth + markerGap;
235143
+ const bodyWidth = Math.max(schema.width - bodyX, 0);
235144
+ const lines = splitTextToSize({
235145
+ value: item.text,
235146
+ characterSpacing,
235147
+ boxWidthInPt: mm2pt(Math.max(bodyWidth, .1)),
235148
+ fontSize,
235149
+ fontKitFont
235150
+ });
235151
+ const height = Math.max(lines.length, 1) * lineHeightMm + (index === items.length - 1 ? 0 : itemSpacing);
235152
+ return {
235153
+ item: item.text,
235154
+ itemIndex: startIndex + index,
235155
+ level: item.level,
235156
+ marker: markers[index],
235157
+ lines,
235158
+ height,
235159
+ markerX,
235160
+ bodyX,
235161
+ bodyWidth
235162
+ };
235163
+ });
235164
+ return {
235165
+ items: layoutItems,
235166
+ totalHeight: layoutItems.reduce((sum, item) => sum + item.height, 0),
235167
+ markerWidth,
235168
+ markerGap,
235169
+ indentSize
235170
+ };
235171
+ };
235172
+ var getDynamicLayoutForList = async (value, args) => {
235173
+ if (args.schema.type !== "list") return { heights: [args.schema.height] };
235174
+ const schema = args.schema;
235175
+ const items = normalizeListItems(value);
235176
+ if (items.length === 0) return { heights: [0] };
235177
+ return {
235178
+ heights: (await calculateListLayout({
235179
+ schema,
235180
+ items,
235181
+ startIndex: 0,
235182
+ options: args.options,
235183
+ _cache: args._cache
235184
+ })).items.map((item) => item.height),
235185
+ avoidFirstUnitOnly: false,
235186
+ patchSplitSchema: ({ start, end, isSplit }) => ({
235187
+ __itemRange: {
235188
+ start,
235189
+ end
235190
+ },
235191
+ __isSplit: isSplit
235192
+ })
235193
+ };
235194
+ };
235195
+ //#endregion
234869
235196
  //#region src/components/UnitPager.tsx
234870
235197
  var { Text } = Typography;
234871
235198
  var icons = {
@@ -234983,6 +235310,17 @@ var UnitPager = ({ size, unitCursor, unitNum, setUnitCursor }) => {
234983
235310
  //#endregion
234984
235311
  //#region src/components/Preview.tsx
234985
235312
  var _cache = /* @__PURE__ */ new Map();
235313
+ var applySchemaChange = (schema, key, value) => {
235314
+ if (key === "position.x") {
235315
+ schema.position.x = value;
235316
+ return;
235317
+ }
235318
+ if (key === "position.y") {
235319
+ schema.position.y = value;
235320
+ return;
235321
+ }
235322
+ schema[key] = value;
235323
+ };
234986
235324
  var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
234987
235325
  const { token } = theme_default.useToken();
234988
235326
  const font = (0, import_react$9.useContext)(FontContext);
@@ -235031,7 +235369,8 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
235031
235369
  _cache,
235032
235370
  getDynamicHeights: (value, args) => {
235033
235371
  switch (args.schema.type) {
235034
- case "table": return getDynamicHeightsForTable(value, args);
235372
+ case "table": return getDynamicLayoutForTable(value, args);
235373
+ case "list": return getDynamicLayoutForList(value, args);
235035
235374
  default: return Promise.resolve([args.schema.height]);
235036
235375
  }
235037
235376
  }
@@ -235087,14 +235426,23 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
235087
235426
  name: schema.name,
235088
235427
  value: newValue
235089
235428
  });
235090
- if (schema.type === "table") {
235429
+ if (schema.type === "table" || schema.type === "list") {
235091
235430
  isNeedInit = true;
235092
235431
  newInputValue = newValue;
235093
235432
  }
235094
235433
  } else {
235095
- const targetSchema = schemasList[pageCursor].find((s) => s.id === schema.id);
235434
+ const pageSchemas = schemasList[pageCursor] || [];
235435
+ const targetSchema = pageSchemas.find((s) => s.id === schema.id);
235096
235436
  if (!targetSchema) return;
235097
- targetSchema[_key] = value;
235437
+ if (_key === "height" && isBlankPdf(template.basePdf)) getDynamicHeightReflowChanges({
235438
+ schemas: pageSchemas,
235439
+ schema: targetSchema,
235440
+ height: value
235441
+ }).forEach(({ key, value, schemaId }) => {
235442
+ const reflowTarget = pageSchemas.find((s) => s.id === schemaId);
235443
+ if (reflowTarget) applySchemaChange(reflowTarget, key, value);
235444
+ });
235445
+ applySchemaChange(targetSchema, _key, value);
235098
235446
  }
235099
235447
  });
235100
235448
  if (isNeedInit && newInputValue !== void 0) init(template, {
@@ -235148,6 +235496,7 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
235148
235496
  pageSizes,
235149
235497
  backgrounds,
235150
235498
  renderSchema: ({ schema, index }) => {
235499
+ const hasInputValue = Boolean(input && Object.prototype.hasOwnProperty.call(input, schema.name));
235151
235500
  const value = schema.readOnly ? replacePlaceholders({
235152
235501
  content: schema.content || "",
235153
235502
  variables: {
@@ -235156,13 +235505,13 @@ var Preview = ({ template, inputs, size, onChangeInput, onPageChange }) => {
235156
235505
  currentPage: index + 1
235157
235506
  },
235158
235507
  schemas: schemasList
235159
- }) : String(input && input[schema.name] || "");
235508
+ }) : String(hasInputValue ? input?.[schema.name] ?? "" : "");
235160
235509
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Renderer, {
235161
235510
  schema,
235162
235511
  basePdf: template.basePdf,
235163
235512
  value,
235164
235513
  mode: isForm ? "form" : "viewer",
235165
- placeholder: schema.content,
235514
+ placeholder: hasInputValue ? void 0 : schema.content,
235166
235515
  tabIndex: index + 100,
235167
235516
  onChange: (arg) => {
235168
235517
  handleOnChangeRenderer(Array.isArray(arg) ? arg : [arg], schema);