@po-ui/ng-components 21.24.0 → 21.25.0

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.
@@ -7012,6 +7012,18 @@ class PoPopoverBaseComponent {
7012
7012
  appendBox = false;
7013
7013
  // Indica se o elemento filho será alinhado nos cantos do elemento pai.
7014
7014
  cornerAligned = false;
7015
+ /**
7016
+ * @optional
7017
+ *
7018
+ * @description
7019
+ *
7020
+ * Define o espaçamento (em pixels) entre o componente alvo (`p-target`) e o `po-popover`.
7021
+ * Útil para componentes com targets pequenos (como ícones) onde o espaçamento padrão é
7022
+ * proporcionalmente muito grande e cria desalinhamento visual.
7023
+ *
7024
+ * @default `8`
7025
+ */
7026
+ offset = 8;
7015
7027
  /**
7016
7028
  * @description
7017
7029
  *
@@ -7150,7 +7162,7 @@ class PoPopoverBaseComponent {
7150
7162
  */
7151
7163
  customClasses = input(undefined, { ...(ngDevMode ? { debugName: "customClasses" } : /* istanbul ignore next */ {}), alias: 'p-custom-classes' });
7152
7164
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: PoPopoverBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
7153
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.18", type: PoPopoverBaseComponent, isStandalone: false, selector: "po-popover-base", inputs: { appendBox: { classPropertyName: "appendBox", publicName: "p-append-in-body", isSignal: false, isRequired: false, transformFunction: convertToBoolean }, cornerAligned: { classPropertyName: "cornerAligned", publicName: "p-corner-aligned", isSignal: false, isRequired: false, transformFunction: null }, target: { classPropertyName: "target", publicName: "p-target", isSignal: false, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "p-title", isSignal: false, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "p-width", isSignal: false, isRequired: false, transformFunction: null }, hideArrow: { classPropertyName: "hideArrow", publicName: "p-hide-arrow", isSignal: false, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "p-position", isSignal: false, isRequired: false, transformFunction: null }, trigger: { classPropertyName: "trigger", publicName: "p-trigger", isSignal: false, isRequired: false, transformFunction: null }, customClasses: { classPropertyName: "customClasses", publicName: "p-custom-classes", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closePopover: "p-close", openPopover: "p-open" }, ngImport: i0, template: '', isInline: true });
7165
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.18", type: PoPopoverBaseComponent, isStandalone: false, selector: "po-popover-base", inputs: { appendBox: { classPropertyName: "appendBox", publicName: "p-append-in-body", isSignal: false, isRequired: false, transformFunction: convertToBoolean }, cornerAligned: { classPropertyName: "cornerAligned", publicName: "p-corner-aligned", isSignal: false, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "p-offset", isSignal: false, isRequired: false, transformFunction: null }, target: { classPropertyName: "target", publicName: "p-target", isSignal: false, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "p-title", isSignal: false, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "p-width", isSignal: false, isRequired: false, transformFunction: null }, hideArrow: { classPropertyName: "hideArrow", publicName: "p-hide-arrow", isSignal: false, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "p-position", isSignal: false, isRequired: false, transformFunction: null }, trigger: { classPropertyName: "trigger", publicName: "p-trigger", isSignal: false, isRequired: false, transformFunction: null }, customClasses: { classPropertyName: "customClasses", publicName: "p-custom-classes", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closePopover: "p-close", openPopover: "p-open" }, ngImport: i0, template: '', isInline: true });
7154
7166
  }
7155
7167
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: PoPopoverBaseComponent, decorators: [{
7156
7168
  type: Component,
@@ -7165,6 +7177,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImpo
7165
7177
  }], cornerAligned: [{
7166
7178
  type: Input,
7167
7179
  args: ['p-corner-aligned']
7180
+ }], offset: [{
7181
+ type: Input,
7182
+ args: ['p-offset']
7168
7183
  }], target: [{
7169
7184
  type: Input,
7170
7185
  args: ['p-target']
@@ -7316,6 +7331,7 @@ class PoPopoverComponent extends PoPopoverBaseComponent {
7316
7331
  }
7317
7332
  showPopover() {
7318
7333
  requestAnimationFrame(() => {
7334
+ this.stabilizePopoverWidth();
7319
7335
  this.setElementsControlPosition();
7320
7336
  this.setPopoverPosition();
7321
7337
  this.setOpacity(1);
@@ -7324,6 +7340,40 @@ class PoPopoverComponent extends PoPopoverBaseComponent {
7324
7340
  this.cd.detectChanges();
7325
7341
  });
7326
7342
  }
7343
+ stabilizePopoverWidth() {
7344
+ if (this.width != null || this.widthPopover != null)
7345
+ return;
7346
+ const el = this.popoverElement?.nativeElement;
7347
+ const target = this.targetElement;
7348
+ if (!el || !target)
7349
+ return;
7350
+ el.style.left = '0px';
7351
+ el.style.top = '0px';
7352
+ const natural = el.getBoundingClientRect().width;
7353
+ const tRect = target.getBoundingClientRect();
7354
+ const cx = tRect.left + tRect.width / 2;
7355
+ const halfTarget = tRect.width / 2;
7356
+ const vp = window.innerWidth;
7357
+ const safety = 2;
7358
+ const candidates = [];
7359
+ if (cx + 15 <= vp)
7360
+ candidates.push(cx + 15 - safety);
7361
+ if (cx - 15 >= 0)
7362
+ candidates.push(vp - cx + 15 - safety);
7363
+ const centered = 2 * Math.min(cx, vp - cx) - safety;
7364
+ if (centered > 0)
7365
+ candidates.push(centered);
7366
+ const leftMax = cx - halfTarget - this.offset - safety;
7367
+ if (leftMax > 0)
7368
+ candidates.push(leftMax);
7369
+ const rightMax = vp - cx - halfTarget - this.offset - safety;
7370
+ if (rightMax > 0)
7371
+ candidates.push(rightMax);
7372
+ const minWidth = 240;
7373
+ const maxFit = candidates.length ? Math.max(...candidates) : natural;
7374
+ this.widthPopover = Math.max(minWidth, Math.min(natural, maxFit));
7375
+ this.cd.detectChanges();
7376
+ }
7327
7377
  ensurePopoverPosition() {
7328
7378
  setTimeout(() => {
7329
7379
  this.setElementsControlPosition();
@@ -7408,8 +7458,7 @@ class PoPopoverComponent extends PoPopoverBaseComponent {
7408
7458
  this.keydownPopoverListener?.();
7409
7459
  }
7410
7460
  setElementsControlPosition() {
7411
- const popoverOffset = 8;
7412
- this.poControlPosition.setElements(this.popoverElement.nativeElement, popoverOffset, this.target, undefined, false, this.cornerAligned);
7461
+ this.poControlPosition.setElements(this.popoverElement.nativeElement, this.offset, this.target, undefined, false, this.cornerAligned);
7413
7462
  }
7414
7463
  focusOnTarget() {
7415
7464
  const el = this.targetElement;
@@ -7518,10 +7567,10 @@ class PoPopoverComponent extends PoPopoverBaseComponent {
7518
7567
  this.disconnectResizeObserver();
7519
7568
  if (!this.popoverElement?.nativeElement)
7520
7569
  return;
7521
- let initialCall = true;
7570
+ let baselineFired = false;
7522
7571
  this.resizeObserver = new ResizeObserver(() => {
7523
- if (initialCall) {
7524
- initialCall = false;
7572
+ if (!baselineFired) {
7573
+ baselineFired = true;
7525
7574
  return;
7526
7575
  }
7527
7576
  this.setElementsControlPosition();
@@ -7613,21 +7662,6 @@ class PoHelperComponent extends PoHelperBaseComponent {
7613
7662
  }
7614
7663
  ngAfterViewInit() {
7615
7664
  PoHelperComponent.instances.push(this);
7616
- queueMicrotask(() => {
7617
- this.setPopoverPositionByScreen();
7618
- });
7619
- }
7620
- setPopoverPositionByScreen() {
7621
- if (!this.target?.nativeElement)
7622
- return;
7623
- const rect = this.target.nativeElement.getBoundingClientRect();
7624
- const screenWidth = window.innerWidth || document.documentElement.clientWidth;
7625
- if (rect.right + 400 > screenWidth) {
7626
- this.popoverPosition = 'left';
7627
- }
7628
- else {
7629
- this.popoverPosition = 'right';
7630
- }
7631
7665
  }
7632
7666
  ngOnChanges(changes) {
7633
7667
  if (changes.size) {
@@ -7748,11 +7782,11 @@ class PoHelperComponent extends PoHelperBaseComponent {
7748
7782
  }
7749
7783
  }
7750
7784
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: PoHelperComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
7751
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.18", type: PoHelperComponent, isStandalone: false, selector: "po-helper", viewQueries: [{ propertyName: "target", first: true, predicate: ["target"], descendants: true, read: ElementRef, static: true }, { propertyName: "popover", first: true, predicate: ["popover"], descendants: true }, { propertyName: "poButton", first: true, predicate: PoButtonComponent, descendants: true, read: ElementRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"po-helper-container po-helper-target\"\n #target\n [attr.tabindex]=\"disabled() ? null : 0\"\n role=\"button\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-expanded]=\"!popover.isHidden\"\n [attr.aria-controls]=\"'popover-content-' + id\"\n [attr.aria-describedby]=\"!popover.isHidden ? 'popover-content-' + id : null\"\n [class.po-helper-disabled]=\"disabled()\"\n (keydown)=\"onKeyDown($event)\"\n (click)=\"openHelperPopover(); emitClick($event); popover.ensurePopoverPosition()\"\n>\n <po-icon [p-icon]=\"helper()?.type === 'info' ? 'ICON_INFO' : 'ICON_HELP'\"></po-icon>\n <po-popover\n #popover\n [p-position]=\"popoverPosition\"\n [p-target]=\"target\"\n [p-title]=\"helper()?.title\"\n [p-append-in-body]=\"appendBox()\"\n p-custom-classes=\"po-helper-popover\"\n p-trigger=\"function\"\n (p-close)=\"handleClose()\"\n (p-open)=\"handleOpen()\"\n >\n <div [id]=\"'popover-content-' + id\" role=\"dialog\" aria-modal=\"false\" tabindex=\"-1\">\n <span class=\"po-helper-content-text\">\n @for (fragment of contentFragments(); track $index) {\n <span\n [class.po-text-bold]=\"fragment.bold\"\n [class.po-text-italic]=\"fragment.italic\"\n [class.po-text-underline]=\"fragment.underline\"\n >{{ fragment.text }}</span\n >\n }\n </span>\n @if (helper()?.type === 'help' && helper()?.footerAction) {\n <po-divider></po-divider>\n <po-link\n class=\"po-helper-footer-action-link\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (p-action)=\"helper()?.footerAction?.action()\"\n [p-label]=\"helper()?.footerAction?.label\"\n >\n </po-link>\n }\n </div>\n </po-popover>\n</div>\n", dependencies: [{ kind: "component", type: PoIconComponent, selector: "po-icon", inputs: ["p-icon"] }, { kind: "component", type: PoPopoverComponent, selector: "po-popover" }, { kind: "component", type: PoLinkComponent, selector: "po-link" }, { kind: "component", type: PoDividerComponent, selector: "po-divider" }] });
7785
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.18", type: PoHelperComponent, isStandalone: false, selector: "po-helper", viewQueries: [{ propertyName: "target", first: true, predicate: ["target"], descendants: true, read: ElementRef, static: true }, { propertyName: "popover", first: true, predicate: ["popover"], descendants: true }, { propertyName: "poButton", first: true, predicate: PoButtonComponent, descendants: true, read: ElementRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"po-helper-container po-helper-target\"\n #target\n [attr.tabindex]=\"disabled() ? null : 0\"\n role=\"button\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-expanded]=\"!popover.isHidden\"\n [attr.aria-controls]=\"'popover-content-' + id\"\n [attr.aria-describedby]=\"!popover.isHidden ? 'popover-content-' + id : null\"\n [class.po-helper-disabled]=\"disabled()\"\n (keydown)=\"onKeyDown($event)\"\n (click)=\"openHelperPopover(); emitClick($event)\"\n>\n <po-icon [p-icon]=\"helper()?.type === 'info' ? 'ICON_INFO' : 'ICON_HELP'\"></po-icon>\n <po-popover\n #popover\n [p-position]=\"popoverPosition\"\n [p-target]=\"target\"\n [p-title]=\"helper()?.title\"\n [p-append-in-body]=\"appendBox()\"\n [p-offset]=\"8\"\n p-custom-classes=\"po-helper-popover\"\n p-trigger=\"function\"\n (p-close)=\"handleClose()\"\n (p-open)=\"handleOpen()\"\n >\n <div [id]=\"'popover-content-' + id\" role=\"dialog\" aria-modal=\"false\" tabindex=\"-1\">\n <span class=\"po-helper-content-text\">\n @for (fragment of contentFragments(); track $index) {\n <span\n [class.po-text-bold]=\"fragment.bold\"\n [class.po-text-italic]=\"fragment.italic\"\n [class.po-text-underline]=\"fragment.underline\"\n >{{ fragment.text }}</span\n >\n }\n </span>\n @if (helper()?.type === 'help' && helper()?.footerAction) {\n <po-divider></po-divider>\n <po-link\n class=\"po-helper-footer-action-link\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (p-action)=\"helper()?.footerAction?.action()\"\n [p-label]=\"helper()?.footerAction?.label\"\n >\n </po-link>\n }\n </div>\n </po-popover>\n</div>\n", dependencies: [{ kind: "component", type: PoIconComponent, selector: "po-icon", inputs: ["p-icon"] }, { kind: "component", type: PoPopoverComponent, selector: "po-popover" }, { kind: "component", type: PoLinkComponent, selector: "po-link" }, { kind: "component", type: PoDividerComponent, selector: "po-divider" }] });
7752
7786
  }
7753
7787
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: PoHelperComponent, decorators: [{
7754
7788
  type: Component,
7755
- args: [{ selector: 'po-helper', standalone: false, template: "<div\n class=\"po-helper-container po-helper-target\"\n #target\n [attr.tabindex]=\"disabled() ? null : 0\"\n role=\"button\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-expanded]=\"!popover.isHidden\"\n [attr.aria-controls]=\"'popover-content-' + id\"\n [attr.aria-describedby]=\"!popover.isHidden ? 'popover-content-' + id : null\"\n [class.po-helper-disabled]=\"disabled()\"\n (keydown)=\"onKeyDown($event)\"\n (click)=\"openHelperPopover(); emitClick($event); popover.ensurePopoverPosition()\"\n>\n <po-icon [p-icon]=\"helper()?.type === 'info' ? 'ICON_INFO' : 'ICON_HELP'\"></po-icon>\n <po-popover\n #popover\n [p-position]=\"popoverPosition\"\n [p-target]=\"target\"\n [p-title]=\"helper()?.title\"\n [p-append-in-body]=\"appendBox()\"\n p-custom-classes=\"po-helper-popover\"\n p-trigger=\"function\"\n (p-close)=\"handleClose()\"\n (p-open)=\"handleOpen()\"\n >\n <div [id]=\"'popover-content-' + id\" role=\"dialog\" aria-modal=\"false\" tabindex=\"-1\">\n <span class=\"po-helper-content-text\">\n @for (fragment of contentFragments(); track $index) {\n <span\n [class.po-text-bold]=\"fragment.bold\"\n [class.po-text-italic]=\"fragment.italic\"\n [class.po-text-underline]=\"fragment.underline\"\n >{{ fragment.text }}</span\n >\n }\n </span>\n @if (helper()?.type === 'help' && helper()?.footerAction) {\n <po-divider></po-divider>\n <po-link\n class=\"po-helper-footer-action-link\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (p-action)=\"helper()?.footerAction?.action()\"\n [p-label]=\"helper()?.footerAction?.label\"\n >\n </po-link>\n }\n </div>\n </po-popover>\n</div>\n" }]
7789
+ args: [{ selector: 'po-helper', standalone: false, template: "<div\n class=\"po-helper-container po-helper-target\"\n #target\n [attr.tabindex]=\"disabled() ? null : 0\"\n role=\"button\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-expanded]=\"!popover.isHidden\"\n [attr.aria-controls]=\"'popover-content-' + id\"\n [attr.aria-describedby]=\"!popover.isHidden ? 'popover-content-' + id : null\"\n [class.po-helper-disabled]=\"disabled()\"\n (keydown)=\"onKeyDown($event)\"\n (click)=\"openHelperPopover(); emitClick($event)\"\n>\n <po-icon [p-icon]=\"helper()?.type === 'info' ? 'ICON_INFO' : 'ICON_HELP'\"></po-icon>\n <po-popover\n #popover\n [p-position]=\"popoverPosition\"\n [p-target]=\"target\"\n [p-title]=\"helper()?.title\"\n [p-append-in-body]=\"appendBox()\"\n [p-offset]=\"8\"\n p-custom-classes=\"po-helper-popover\"\n p-trigger=\"function\"\n (p-close)=\"handleClose()\"\n (p-open)=\"handleOpen()\"\n >\n <div [id]=\"'popover-content-' + id\" role=\"dialog\" aria-modal=\"false\" tabindex=\"-1\">\n <span class=\"po-helper-content-text\">\n @for (fragment of contentFragments(); track $index) {\n <span\n [class.po-text-bold]=\"fragment.bold\"\n [class.po-text-italic]=\"fragment.italic\"\n [class.po-text-underline]=\"fragment.underline\"\n >{{ fragment.text }}</span\n >\n }\n </span>\n @if (helper()?.type === 'help' && helper()?.footerAction) {\n <po-divider></po-divider>\n <po-link\n class=\"po-helper-footer-action-link\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (p-action)=\"helper()?.footerAction?.action()\"\n [p-label]=\"helper()?.footerAction?.label\"\n >\n </po-link>\n }\n </div>\n </po-popover>\n</div>\n" }]
7756
7790
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { target: [{
7757
7791
  type: ViewChild,
7758
7792
  args: ['target', { read: ElementRef, static: true }]