@pdfme/ui 6.1.13-dev.1 → 6.1.13-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.
@@ -0,0 +1,11 @@
1
+ import type { Size } from '@pdfme/common';
2
+ export type ViewportSize = {
3
+ height: number;
4
+ width: number;
5
+ };
6
+ export type ContainerBox = {
7
+ clientHeight: number;
8
+ clientWidth: number;
9
+ getBoundingClientRect: () => Pick<DOMRect, 'bottom' | 'left' | 'right' | 'top'>;
10
+ };
11
+ export declare const measureUiContainerSize: (container: ContainerBox, viewport: ViewportSize) => Size;
package/dist/index.js CHANGED
@@ -56107,6 +56107,25 @@ var BACKGROUND_COLOR = "rgb(74, 74, 74)";
56107
56107
  var DESIGNER_CLASSNAME = "pdfme-designer-";
56108
56108
  var UI_CLASSNAME = "pdfme-ui-";
56109
56109
  //#endregion
56110
+ //#region src/containerSize.ts
56111
+ var visibleIntersection = (start, end, viewportSize) => Math.max(0, Math.min(end, viewportSize) - Math.max(start, 0));
56112
+ var capOverflowToViewport = (layout, visible, viewportSize) => layout > viewportSize ? Math.min(layout, visible) : layout;
56113
+ var measureUiContainerSize = (container, viewport) => {
56114
+ const layoutWidth = container.clientWidth || viewport.width;
56115
+ const layoutHeight = container.clientHeight || viewport.height;
56116
+ const rect = container.getBoundingClientRect();
56117
+ const visibleWidth = visibleIntersection(rect.left, rect.right, viewport.width);
56118
+ const visibleHeight = visibleIntersection(rect.top, rect.bottom, viewport.height);
56119
+ if (visibleWidth === 0 || visibleHeight === 0) return {
56120
+ height: layoutHeight,
56121
+ width: layoutWidth
56122
+ };
56123
+ return {
56124
+ height: capOverflowToViewport(layoutHeight, visibleHeight, viewport.height),
56125
+ width: capOverflowToViewport(layoutWidth, visibleWidth, viewport.width)
56126
+ };
56127
+ };
56128
+ //#endregion
56110
56129
  //#region ../../node_modules/hotkeys-js/dist/hotkeys-js.js
56111
56130
  /*!
56112
56131
  * hotkeys-js v4.0.7
@@ -77436,15 +77455,10 @@ var BaseUIClass = class {
77436
77455
  _defineProperty$14(this, "options", {});
77437
77456
  _defineProperty$14(this, "setSize", debounce$2(() => {
77438
77457
  if (!this.domContainer) return;
77439
- const rect = this.domContainer.getBoundingClientRect();
77440
- const vw = window.innerWidth;
77441
- const vh = window.innerHeight;
77442
- const visibleWidth = Math.max(0, Math.min(rect.right, vw) - Math.max(rect.left, 0));
77443
- const visibleHeight = Math.max(0, Math.min(rect.bottom, vh) - Math.max(rect.top, 0));
77444
- this.size = {
77445
- height: visibleHeight,
77446
- width: visibleWidth
77447
- };
77458
+ this.size = measureUiContainerSize(this.domContainer, {
77459
+ height: window.innerHeight,
77460
+ width: window.innerWidth
77461
+ });
77448
77462
  this.render();
77449
77463
  }, 100));
77450
77464
  _defineProperty$14(this, "resizeObserver", new ResizeObserver(this.setSize));
@@ -77454,10 +77468,10 @@ var BaseUIClass = class {
77454
77468
  this.template = cloneDeep$1(template);
77455
77469
  this.options = options;
77456
77470
  const container = this.domContainer;
77457
- this.size = {
77458
- height: container.clientHeight || window.innerHeight,
77459
- width: container.clientWidth || window.innerWidth
77460
- };
77471
+ this.size = measureUiContainerSize(container, {
77472
+ height: window.innerHeight,
77473
+ width: window.innerWidth
77474
+ });
77461
77475
  this.resizeObserver.observe(container);
77462
77476
  const { lang, font } = options;
77463
77477
  if (lang) this.lang = lang;