@pdfme/ui 6.1.13-dev.4 → 6.1.13-dev.8

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/class.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare abstract class BaseUIClass {
12
12
  private readonly setSize;
13
13
  resizeObserver: ResizeObserver;
14
14
  constructor(props: UIProps);
15
- protected getLang(): "ar" | "de" | "en" | "es" | "fr" | "it" | "ja" | "ko" | "pl" | "th" | "zh" | "zh-TW";
15
+ protected getLang(): "ar" | "de" | "en" | "es" | "fr" | "it" | "ja" | "ko" | "pl" | "th" | "tr" | "zh" | "zh-TW";
16
16
  protected getFont(): Record<string, {
17
17
  data: string | ArrayBuffer | Uint8Array<ArrayBuffer>;
18
18
  fallback?: boolean | undefined;
@@ -7,5 +7,6 @@ export declare const LEFT_SIDEBAR_WIDTH = 45;
7
7
  export declare const RIGHT_SIDEBAR_WIDTH = 400;
8
8
  export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
9
9
  export declare const DEFAULT_MAX_ZOOM = 2;
10
+ export declare const PAGE_SWITCH_REMAINING_RATIO = 0.25;
10
11
  export declare const DESIGNER_CLASSNAME = "pdfme-designer-";
11
12
  export declare const UI_CLASSNAME = "pdfme-ui-";
package/dist/helper.d.ts CHANGED
@@ -55,6 +55,12 @@ export declare const moveCommandToChangeSchemasArg: (props: {
55
55
  schemaId: string;
56
56
  }[];
57
57
  export declare const getPagesScrollTopByIndex: (pageSizes: Size[], index: number, scale: number) => number;
58
+ export declare const getVisibleOverlap: (containerRect: DOMRect, elementRect: DOMRect) => {
59
+ width: number;
60
+ height: number;
61
+ area: number;
62
+ };
63
+ export declare const getStickyScrollPageIndex: (container: HTMLElement, papers: Array<HTMLElement | null | undefined>, pageCursor: number) => number;
58
64
  export type ZoomMode = 'manual' | 'fit-width' | 'fit-height';
59
65
  export type ZoomAnchor = {
60
66
  pageIndex: number;
package/dist/index.js CHANGED
@@ -45375,6 +45375,7 @@ var Lang = _enum([
45375
45375
  "ko",
45376
45376
  "ar",
45377
45377
  "th",
45378
+ "tr",
45378
45379
  "pl",
45379
45380
  "it",
45380
45381
  "de",
@@ -56104,6 +56105,7 @@ var import_client = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
56104
56105
  var DESTROYED_ERR_MSG = "[@pdfme/ui] this instance is already destroyed";
56105
56106
  var SELECTABLE_CLASSNAME = "selectable";
56106
56107
  var BACKGROUND_COLOR = "rgb(74, 74, 74)";
56108
+ var PAGE_SWITCH_REMAINING_RATIO = .25;
56107
56109
  var DESIGNER_CLASSNAME = "pdfme-designer-";
56108
56110
  var UI_CLASSNAME = "pdfme-ui-";
56109
56111
  //#endregion
@@ -57367,6 +57369,113 @@ var dictionaries = {
57367
57369
  "schemas.list.indentItem": "เพิ่มย่อหน้า",
57368
57370
  "schemas.list.outdentItem": "ลดย่อหน้า"
57369
57371
  },
57372
+ tr: {
57373
+ cancel: "İptal",
57374
+ close: "Kapat",
57375
+ clear: "Temizle",
57376
+ set: "Ayarla",
57377
+ field: "alan",
57378
+ fieldName: "Ad",
57379
+ align: "Hizala",
57380
+ width: "Genişlik",
57381
+ height: "Yükseklik",
57382
+ opacity: "Opaklık",
57383
+ rotate: "Döndür",
57384
+ required: "Zorunlu",
57385
+ editable: "Düzenlenebilir",
57386
+ edit: "Düzenle",
57387
+ plsInputName: "Lütfen bir ad girin",
57388
+ fieldMustUniq: "Alan adı benzersiz olmalı",
57389
+ notUniq: "(Benzersiz olmayan ad)",
57390
+ noKeyName: "Adsız",
57391
+ fieldsList: "Alan Listesi",
57392
+ editField: "Alanı Düzenle",
57393
+ type: "Tür",
57394
+ errorOccurred: "Bir hata oluştu",
57395
+ errorBulkUpdateFieldName: "Öğe sayısı değiştiği için değişiklik kaydedilemedi.",
57396
+ commitBulkUpdateFieldName: "Değişiklikleri Kaydet",
57397
+ bulkUpdateFieldName: "Alan adlarını toplu güncelle",
57398
+ addPageAfter: "Sonrasına Sayfa Ekle",
57399
+ removePage: "Mevcut Sayfayı Kaldır",
57400
+ removePageConfirm: "Bu sayfayı silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.",
57401
+ zoomIn: "Yakınlaştır",
57402
+ zoomOut: "Uzaklaştır",
57403
+ fitWidth: "Genişliğe sığdır",
57404
+ fitHeight: "Yüksekliğe sığdır",
57405
+ "validation.hexColor": "Lütfen geçerli bir hex renk kodu girin.",
57406
+ "validation.uniqueName": "Lütfen benzersiz bir ad girin.",
57407
+ "validation.dateTimeFormat": "Geçersiz tarih saat biçimi.",
57408
+ "validation.outOfBounds": "Sayfa sınırlarını aşıyor.",
57409
+ "schemas.color": "Renk",
57410
+ "schemas.borderWidth": "Kenarlık Genişliği",
57411
+ "schemas.borderColor": "Kenarlık Rengi",
57412
+ "schemas.backgroundColor": "Arka Plan Rengi",
57413
+ "schemas.textColor": "Metin Rengi",
57414
+ "schemas.bgColor": "Arka Plan Rengi",
57415
+ "schemas.horizontal": "Yatay",
57416
+ "schemas.vertical": "Dikey",
57417
+ "schemas.left": "Sol",
57418
+ "schemas.center": "Orta",
57419
+ "schemas.right": "Sağ",
57420
+ "schemas.top": "Üst",
57421
+ "schemas.middle": "Orta",
57422
+ "schemas.bottom": "Alt",
57423
+ "schemas.padding": "İç Boşluk",
57424
+ "schemas.text.fontName": "Yazı Tipi Adı",
57425
+ "schemas.text.size": "Boyut",
57426
+ "schemas.text.spacing": "Aralık",
57427
+ "schemas.text.textAlign": "Metin Hizası",
57428
+ "schemas.text.verticalAlign": "Dikey Hizalama",
57429
+ "schemas.text.lineHeight": "Satır Yüksekliği",
57430
+ "schemas.text.min": "En Az",
57431
+ "schemas.text.max": "En Çok",
57432
+ "schemas.text.fit": "Sığdır",
57433
+ "schemas.text.dynamicFontSize": "Dinamik Yazı Tipi Boyutu",
57434
+ "schemas.text.overflow": "Taşma",
57435
+ "schemas.text.overflowVisible": "Görünür",
57436
+ "schemas.text.overflowExpand": "Genişlet",
57437
+ "schemas.text.format": "Biçim",
57438
+ "schemas.text.plain": "Düz",
57439
+ "schemas.text.inlineMarkdown": "Satır İçi Markdown Kullan",
57440
+ "schemas.text.markdownFonts": "Markdown Yazı Tipleri",
57441
+ "schemas.text.boldFont": "Kalın Yazı Tipi",
57442
+ "schemas.text.italicFont": "İtalik Yazı Tipi",
57443
+ "schemas.text.boldItalicFont": "Kalın İtalik Yazı Tipi",
57444
+ "schemas.text.codeFont": "Kod Yazı Tipi",
57445
+ "schemas.text.variantFallback": "Varyant Geri Dönüşü",
57446
+ "schemas.text.synthetic": "Yapay Stil",
57447
+ "schemas.text.error": "Hata",
57448
+ "schemas.radius": "Yarıçap",
57449
+ "schemas.mvt.typingInstructions": "Değişken eklemek için süslü parantez içine kelime yazın, örneğin",
57450
+ "schemas.mvt.sampleField": "ad",
57451
+ "schemas.mvt.variablesSampleData": "Değişken Örnek Verisi",
57452
+ "schemas.mvt.placeholderDynamicVariable": "Yer Tutucu Dinamik Değişken",
57453
+ "schemas.barcodes.barColor": "Çubuk Rengi",
57454
+ "schemas.barcodes.includetext": "Metni Dahil Et",
57455
+ "schemas.table.alternateBackgroundColor": "Alternatif Arka Plan Rengi",
57456
+ "schemas.table.tableStyle": "Tablo Stili",
57457
+ "schemas.table.showHead": "Başlığı Göster",
57458
+ "schemas.table.repeatHead": "Başlığı Tekrarla",
57459
+ "schemas.table.headStyle": "Başlık Stili",
57460
+ "schemas.table.bodyStyle": "Gövde Stili",
57461
+ "schemas.table.columnStyle": "Sütun Stili",
57462
+ "schemas.date.format": "Tarih Biçimi",
57463
+ "schemas.date.locale": "Yerel Ayar",
57464
+ "schemas.select.options": "Seçenekler",
57465
+ "schemas.select.optionPlaceholder": "Bir seçenek girin",
57466
+ "schemas.radioGroup.groupName": "Grup Adı",
57467
+ "schemas.list.listStyle": "Liste Stili",
57468
+ "schemas.list.bullet": "Madde İşaretli",
57469
+ "schemas.list.ordered": "Numaralı",
57470
+ "schemas.list.markerWidth": "İşaret Genişliği",
57471
+ "schemas.list.markerGap": "İşaret Aralığı",
57472
+ "schemas.list.indentSize": "Girinti Boyutu",
57473
+ "schemas.list.itemSpacing": "Öğe Aralığı",
57474
+ "schemas.list.addItem": "Öğe Ekle",
57475
+ "schemas.list.removeItem": "Öğe Kaldır",
57476
+ "schemas.list.indentItem": "Girintiyi Artır",
57477
+ "schemas.list.outdentItem": "Girintiyi Azalt"
57478
+ },
57370
57479
  it: {
57371
57480
  cancel: "Annulla",
57372
57481
  close: "Chiudi",
@@ -77335,6 +77444,44 @@ var moveCommandToChangeSchemasArg = (props) => {
77335
77444
  var getPagesScrollTopByIndex = (pageSizes, index, scale) => {
77336
77445
  return pageSizes.slice(0, index).reduce((acc, cur) => acc + (cur.height * ZOOM + 30 * scale) * scale, 0);
77337
77446
  };
77447
+ var getVisibleOverlap = (containerRect, elementRect) => {
77448
+ const width = Math.max(0, Math.min(containerRect.right, elementRect.right) - Math.max(containerRect.left, elementRect.left));
77449
+ const height = Math.max(0, Math.min(containerRect.bottom, elementRect.bottom) - Math.max(containerRect.top, elementRect.top));
77450
+ return {
77451
+ width,
77452
+ height,
77453
+ area: width * height
77454
+ };
77455
+ };
77456
+ var VERTICAL_SCROLL_EDGE_EPSILON = 1;
77457
+ var isAtVerticalScrollEdge = (container) => {
77458
+ const maxScrollTop = container.scrollHeight - container.clientHeight;
77459
+ if (maxScrollTop <= 0) return false;
77460
+ const { scrollTop } = container;
77461
+ return scrollTop <= VERTICAL_SCROLL_EDGE_EPSILON || scrollTop >= maxScrollTop - VERTICAL_SCROLL_EDGE_EPSILON;
77462
+ };
77463
+ var getStickyScrollPageIndex = (container, papers, pageCursor) => {
77464
+ const containerRect = container.getBoundingClientRect();
77465
+ const stickyHeight = containerRect.height * PAGE_SWITCH_REMAINING_RATIO;
77466
+ let bestPageIndex = pageCursor;
77467
+ let bestVisibleArea = 0;
77468
+ let currentVisibleHeight = 0;
77469
+ let currentVisibleArea = 0;
77470
+ papers.forEach((paper, pageIndex) => {
77471
+ if (!paper) return;
77472
+ const { height, area } = getVisibleOverlap(containerRect, paper.getBoundingClientRect());
77473
+ if (pageIndex === pageCursor) {
77474
+ currentVisibleHeight = height;
77475
+ currentVisibleArea = area;
77476
+ }
77477
+ if (area > bestVisibleArea) {
77478
+ bestVisibleArea = area;
77479
+ bestPageIndex = pageIndex;
77480
+ }
77481
+ });
77482
+ if (bestVisibleArea <= 0) return pageCursor;
77483
+ return !isAtVerticalScrollEdge(container) && currentVisibleArea > 0 && currentVisibleHeight >= stickyHeight ? pageCursor : bestPageIndex;
77484
+ };
77338
77485
  var MIN_ZOOM = .25;
77339
77486
  var FIT_GUTTER = 40;
77340
77487
  var clampZoomLevel = (zoomLevel, maxZoom, minZoom = MIN_ZOOM) => Math.min(Math.max(zoomLevel, minZoom), maxZoom);
@@ -88044,7 +88191,7 @@ function getPxValue$5(val) {
88044
88191
  /**
88045
88192
  * Get visible area of element
88046
88193
  */
88047
- function getVisibleArea$6(initArea, scrollerList) {
88194
+ function getVisibleArea$5(initArea, scrollerList) {
88048
88195
  const visibleArea = { ...initArea };
88049
88196
  (scrollerList || []).forEach((ele) => {
88050
88197
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
@@ -88222,8 +88369,8 @@ function useAlign$5(open, popupEle, target, placement, builtinPlacements, popupA
88222
88369
  const VISIBLE_FIRST = "visibleFirst";
88223
88370
  if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) htmlRegion = VISIBLE;
88224
88371
  const isVisibleFirst = htmlRegion === VISIBLE_FIRST;
88225
- const scrollRegionArea = getVisibleArea$6(scrollRegion, scrollerList);
88226
- const visibleRegionArea = getVisibleArea$6(visibleRegion, scrollerList);
88372
+ const scrollRegionArea = getVisibleArea$5(scrollRegion, scrollerList);
88373
+ const visibleRegionArea = getVisibleArea$5(visibleRegion, scrollerList);
88227
88374
  const visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
88228
88375
  const adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
88229
88376
  popupElement.style.left = "auto";
@@ -95520,7 +95667,7 @@ function getPxValue$4(val) {
95520
95667
  /**
95521
95668
  * Get visible area of element
95522
95669
  */
95523
- function getVisibleArea$5(initArea, scrollerList) {
95670
+ function getVisibleArea$4(initArea, scrollerList) {
95524
95671
  const visibleArea = { ...initArea };
95525
95672
  (scrollerList || []).forEach((ele) => {
95526
95673
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
@@ -95698,8 +95845,8 @@ function useAlign$4(open, popupEle, target, placement, builtinPlacements, popupA
95698
95845
  const VISIBLE_FIRST = "visibleFirst";
95699
95846
  if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) htmlRegion = VISIBLE;
95700
95847
  const isVisibleFirst = htmlRegion === VISIBLE_FIRST;
95701
- const scrollRegionArea = getVisibleArea$5(scrollRegion, scrollerList);
95702
- const visibleRegionArea = getVisibleArea$5(visibleRegion, scrollerList);
95848
+ const scrollRegionArea = getVisibleArea$4(scrollRegion, scrollerList);
95849
+ const visibleRegionArea = getVisibleArea$4(visibleRegion, scrollerList);
95703
95850
  const visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
95704
95851
  const adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
95705
95852
  popupElement.style.left = "auto";
@@ -101646,7 +101793,7 @@ function getPxValue$3(val) {
101646
101793
  /**
101647
101794
  * Get visible area of element
101648
101795
  */
101649
- function getVisibleArea$4(initArea, scrollerList) {
101796
+ function getVisibleArea$3(initArea, scrollerList) {
101650
101797
  const visibleArea = { ...initArea };
101651
101798
  (scrollerList || []).forEach((ele) => {
101652
101799
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
@@ -101824,8 +101971,8 @@ function useAlign$3(open, popupEle, target, placement, builtinPlacements, popupA
101824
101971
  const VISIBLE_FIRST = "visibleFirst";
101825
101972
  if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) htmlRegion = VISIBLE;
101826
101973
  const isVisibleFirst = htmlRegion === VISIBLE_FIRST;
101827
- const scrollRegionArea = getVisibleArea$4(scrollRegion, scrollerList);
101828
- const visibleRegionArea = getVisibleArea$4(visibleRegion, scrollerList);
101974
+ const scrollRegionArea = getVisibleArea$3(scrollRegion, scrollerList);
101975
+ const visibleRegionArea = getVisibleArea$3(visibleRegion, scrollerList);
101829
101976
  const visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
101830
101977
  const adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
101831
101978
  popupElement.style.left = "auto";
@@ -104012,7 +104159,7 @@ function getPxValue$2(val) {
104012
104159
  /**
104013
104160
  * Get visible area of element
104014
104161
  */
104015
- function getVisibleArea$3(initArea, scrollerList) {
104162
+ function getVisibleArea$2(initArea, scrollerList) {
104016
104163
  const visibleArea = { ...initArea };
104017
104164
  (scrollerList || []).forEach((ele) => {
104018
104165
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
@@ -104190,8 +104337,8 @@ function useAlign$2(open, popupEle, target, placement, builtinPlacements, popupA
104190
104337
  const VISIBLE_FIRST = "visibleFirst";
104191
104338
  if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) htmlRegion = VISIBLE;
104192
104339
  const isVisibleFirst = htmlRegion === VISIBLE_FIRST;
104193
- const scrollRegionArea = getVisibleArea$3(scrollRegion, scrollerList);
104194
- const visibleRegionArea = getVisibleArea$3(visibleRegion, scrollerList);
104340
+ const scrollRegionArea = getVisibleArea$2(scrollRegion, scrollerList);
104341
+ const visibleRegionArea = getVisibleArea$2(visibleRegion, scrollerList);
104195
104342
  const visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
104196
104343
  const adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
104197
104344
  popupElement.style.left = "auto";
@@ -106068,7 +106215,7 @@ function getPxValue$1(val) {
106068
106215
  /**
106069
106216
  * Get visible area of element
106070
106217
  */
106071
- function getVisibleArea$2(initArea, scrollerList) {
106218
+ function getVisibleArea$1(initArea, scrollerList) {
106072
106219
  const visibleArea = { ...initArea };
106073
106220
  (scrollerList || []).forEach((ele) => {
106074
106221
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
@@ -106246,8 +106393,8 @@ function useAlign$1(open, popupEle, target, placement, builtinPlacements, popupA
106246
106393
  const VISIBLE_FIRST = "visibleFirst";
106247
106394
  if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) htmlRegion = VISIBLE;
106248
106395
  const isVisibleFirst = htmlRegion === VISIBLE_FIRST;
106249
- const scrollRegionArea = getVisibleArea$2(scrollRegion, scrollerList);
106250
- const visibleRegionArea = getVisibleArea$2(visibleRegion, scrollerList);
106396
+ const scrollRegionArea = getVisibleArea$1(scrollRegion, scrollerList);
106397
+ const visibleRegionArea = getVisibleArea$1(visibleRegion, scrollerList);
106251
106398
  const visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
106252
106399
  const adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
106253
106400
  popupElement.style.left = "auto";
@@ -122383,27 +122530,10 @@ var useZoom = ({ baseScale, maxZoom, pageCursor, pageSizes, containerRef, paperR
122383
122530
  fitHeight: () => fitZoom("fit-height")
122384
122531
  };
122385
122532
  };
122386
- var getVisibleArea$1 = (containerRect, elementRect) => {
122387
- return Math.max(0, Math.min(containerRect.right, elementRect.right) - Math.max(containerRect.left, elementRect.left)) * Math.max(0, Math.min(containerRect.bottom, elementRect.bottom) - Math.max(containerRect.top, elementRect.top));
122388
- };
122389
- var getMostVisiblePageIndex = (container, paperRefs, pageCursor) => {
122390
- const containerRect = container.getBoundingClientRect();
122391
- let bestPageIndex = pageCursor;
122392
- let bestVisibleArea = 0;
122393
- paperRefs.current.forEach((paper, pageIndex) => {
122394
- if (!paper) return;
122395
- const visibleArea = getVisibleArea$1(containerRect, paper.getBoundingClientRect());
122396
- if (visibleArea > bestVisibleArea) {
122397
- bestVisibleArea = visibleArea;
122398
- bestPageIndex = pageIndex;
122399
- }
122400
- });
122401
- return bestVisibleArea > 0 ? bestPageIndex : pageCursor;
122402
- };
122403
122533
  var useScrollPageCursor = ({ ref, paperRefs, pageSizes, scale, pageCursor, onChangePageCursor }) => {
122404
122534
  const onScroll = (0, import_react$9.useCallback)(() => {
122405
122535
  if (!pageSizes[0] || !ref.current) return;
122406
- const _pageCursor = getMostVisiblePageIndex(ref.current, paperRefs, pageCursor);
122536
+ const _pageCursor = getStickyScrollPageIndex(ref.current, paperRefs.current, pageCursor);
122407
122537
  if (_pageCursor !== pageCursor) onChangePageCursor(_pageCursor);
122408
122538
  }, [
122409
122539
  onChangePageCursor,