@ship-ui/core 0.17.15 → 0.17.16

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.
@@ -3258,7 +3258,7 @@
3258
3258
  },
3259
3259
  {
3260
3260
  "name": "search-menu-example",
3261
- "html": "<sh-menu [searchable]=\"true\">\n <button shButton class=\"outlined\">Open searchable menu</button>\n <ng-container menu>\n @for (item of filteredItems; track item.value) {\n <button (click)=\"select(item)\" [class.selected]=\"selected === item.value\">\n <p>\n hello world\n <br />\n {{ item.label }}\n </p>\n </button>\n }\n </ng-container>\n</sh-menu>\n",
3261
+ "html": "<sh-menu [searchable]=\"true\">\n <button shButton class=\"outlined\">Open searchable menu</button>\n <ng-container menu>\n @for (item of filteredItems; track item.value) {\n <button (click)=\"select(item)\" [class.selected]=\"selected === item.value\">\n <p>\n hello world\n <br />\n {{ item.label }}\n </p>\n </button>\n }\n </ng-container>\n</sh-menu>\n\n<sh-menu [searchable]=\"true\">\n <button shButton class=\"outlined\">Open searchable menu</button>\n <ng-container menu>\n @for (item of filteredItems; track item.value) {\n <button (click)=\"select(item)\" [class.selected]=\"selected === item.value\">\n <div class=\"option-col\">\n {{ item.label }} asdlkjadskljjkladsjkldaljkdaslkjad jklsjkl dasjkld as\n <p>hello world but im extra long so i should wrap to the next line</p>\n </div>\n </button>\n }\n </ng-container>\n</sh-menu>\n",
3262
3262
  "ts": "import { Component } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { ShipButton, ShipMenu } from 'ship-ui';\n\n@Component({\n selector: 'sh-search-menu-example',\n templateUrl: './search-menu-example.html',\n styleUrls: ['./search-menu-example.scss'],\n imports: [FormsModule, ShipMenu, ShipButton],\n standalone: true,\n})\nexport class SearchMenuExample {\n menuItems = [\n { label: 'Dashboard', value: 'dashboard' },\n { label: 'Users', value: 'users' },\n { label: 'Settings', value: 'settings' },\n { label: 'Billing', value: 'billing' },\n { label: 'Support', value: 'support' },\n ];\n search = '';\n selected: string | null = null;\n\n get filteredItems() {\n return this.menuItems.filter((item) => item.label.toLowerCase().includes(this.search.toLowerCase()));\n }\n\n select(item: any) {\n this.selected = item.value;\n }\n}\n"
3263
3263
  },
3264
3264
  {
@@ -7046,34 +7046,39 @@ class ShipTooltipWrapper {
7046
7046
  const tooltipRect = tooltipEl.getBoundingClientRect();
7047
7047
  if (tooltipRect.width === 0 && tooltipRect.height === 0)
7048
7048
  return;
7049
- const outOfBoundsTop = hostRect.top - tooltipRect.height < 0;
7049
+ if (this.SUPPORTS_ANCHOR) {
7050
+ const isPlacedBelow = tooltipRect.top > hostRect.top;
7051
+ if (this.isBelow() !== isPlacedBelow) {
7052
+ this.isBelow.set(isPlacedBelow);
7053
+ }
7054
+ return;
7055
+ }
7056
+ const gap = 12;
7057
+ const outOfBoundsTop = hostRect.top - tooltipRect.height - gap < 0;
7050
7058
  if (this.isBelow() !== outOfBoundsTop) {
7051
7059
  this.isBelow.set(outOfBoundsTop);
7052
7060
  }
7053
- if (!this.SUPPORTS_ANCHOR) {
7054
- const tooltipRect = tooltipEl.getBoundingClientRect();
7055
- let newTop = hostRect.top - tooltipRect.height;
7056
- let newLeft = hostRect.left + hostRect.width / 2 - tooltipRect.width / 2;
7057
- if (outOfBoundsTop) {
7058
- newTop = hostRect.top + hostRect.height;
7059
- }
7060
- if (newLeft + tooltipRect.width > window?.innerWidth) {
7061
- newLeft = hostRect.right - tooltipRect.width / 2;
7062
- }
7063
- if (newLeft < 0) {
7064
- newLeft = -(tooltipRect.width / 2);
7065
- }
7066
- const leftStyle = `${newLeft}px`;
7067
- const topStyle = `${newTop}px`;
7068
- if (tooltipEl.style.left !== leftStyle) {
7069
- this.#renderer.setStyle(tooltipEl, 'left', leftStyle);
7070
- }
7071
- if (tooltipEl.style.top !== topStyle) {
7072
- this.#renderer.setStyle(tooltipEl, 'top', topStyle);
7073
- }
7074
- if (tooltipEl.style.position !== 'fixed') {
7075
- this.#renderer.setStyle(tooltipEl, 'position', 'fixed');
7076
- }
7061
+ let newTop = hostRect.top - tooltipRect.height - gap;
7062
+ let newLeft = hostRect.left + hostRect.width / 2 - tooltipRect.width / 2;
7063
+ if (outOfBoundsTop) {
7064
+ newTop = hostRect.top + hostRect.height;
7065
+ }
7066
+ if (newLeft + tooltipRect.width > window?.innerWidth) {
7067
+ newLeft = hostRect.right - tooltipRect.width / 2;
7068
+ }
7069
+ if (newLeft < 0) {
7070
+ newLeft = -(tooltipRect.width / 2);
7071
+ }
7072
+ const leftStyle = `${newLeft}px`;
7073
+ const topStyle = `${newTop}px`;
7074
+ if (tooltipEl.style.left !== leftStyle) {
7075
+ this.#renderer.setStyle(tooltipEl, 'left', leftStyle);
7076
+ }
7077
+ if (tooltipEl.style.top !== topStyle) {
7078
+ this.#renderer.setStyle(tooltipEl, 'top', topStyle);
7079
+ }
7080
+ if (tooltipEl.style.position !== 'fixed') {
7081
+ this.#renderer.setStyle(tooltipEl, 'position', 'fixed');
7077
7082
  }
7078
7083
  };
7079
7084
  }
@@ -7147,7 +7152,7 @@ class ShipTooltip {
7147
7152
  this.#elementRef = inject((ElementRef));
7148
7153
  this.#viewContainerRef = inject(ViewContainerRef);
7149
7154
  this.#environmentInjector = inject(EnvironmentInjector);
7150
- this.#renderer = inject(Renderer2);
7155
+ this.debounceTimer = null;
7151
7156
  this.DEBOUNCE_DELAY = 500;
7152
7157
  this.anchorName = `--${generateUniqueId()}`;
7153
7158
  this.isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : []));
@@ -7156,7 +7161,6 @@ class ShipTooltip {
7156
7161
  #elementRef;
7157
7162
  #viewContainerRef;
7158
7163
  #environmentInjector;
7159
- #renderer;
7160
7164
  onMouseEnter() {
7161
7165
  if (openRef?.component.anchorName !== this.anchorName) {
7162
7166
  this.cleanupTooltip();
@@ -7215,6 +7219,10 @@ class ShipTooltip {
7215
7219
  cleanupTooltip() {
7216
7220
  if (openRef?.wrapperComponentRef) {
7217
7221
  openRef.component.cancelCleanupTimer();
7222
+ const nativeEl = openRef.wrapperComponentRef.location.nativeElement;
7223
+ if (nativeEl && typeof nativeEl.matches === 'function' && nativeEl.matches(':popover-open')) {
7224
+ nativeEl.hidePopover();
7225
+ }
7218
7226
  openRef.wrapperComponentRef.destroy();
7219
7227
  openRef.component.isOpen.set(false);
7220
7228
  openRef = null;