@ship-ui/core 0.17.7 → 0.17.9
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/assets/mcp/components.json +2437 -2431
- package/fesm2022/ship-ui-core.mjs +97 -57
- package/fesm2022/ship-ui-core.mjs.map +1 -1
- package/package.json +2 -2
- package/snippets/ship-ui.code-snippets +274 -274
- package/styles/components/ship-popover.scss +7 -1
- package/styles/components/ship-toggle-card.scss +5 -2
- package/types/ship-ui-core.d.ts +2 -3
|
@@ -2709,61 +2709,106 @@ class ShipPopover {
|
|
|
2709
2709
|
}
|
|
2710
2710
|
return this.#document.documentElement;
|
|
2711
2711
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2712
|
+
/**
|
|
2713
|
+
* Position generators that mirror the CSS position-try-fallbacks.
|
|
2714
|
+
* Each returns { left, top } for the popover-content in fixed coordinates.
|
|
2715
|
+
*/
|
|
2716
|
+
// bottom span-right: below trigger, left edge aligned with trigger left
|
|
2717
|
+
#bottomSpanRight(t, _m) {
|
|
2718
|
+
return { left: t.left, top: t.bottom + BASE_SPACE };
|
|
2719
|
+
}
|
|
2720
|
+
// top span-right: above trigger, left edge aligned with trigger left
|
|
2721
|
+
#topSpanRight(t, m) {
|
|
2722
|
+
return { left: t.left, top: t.top - m.height - BASE_SPACE };
|
|
2723
|
+
}
|
|
2724
|
+
// bottom span-left: below trigger, right edge aligned with trigger right
|
|
2725
|
+
#bottomSpanLeft(t, m) {
|
|
2726
|
+
return { left: t.right - m.width, top: t.bottom + BASE_SPACE };
|
|
2727
|
+
}
|
|
2728
|
+
// top span-left: above trigger, right edge aligned with trigger right
|
|
2729
|
+
#topSpanLeft(t, m) {
|
|
2730
|
+
return { left: t.right - m.width, top: t.top - m.height - BASE_SPACE };
|
|
2731
|
+
}
|
|
2732
|
+
// right span-bottom: to the right of trigger, top edge aligned with trigger top
|
|
2733
|
+
#rightSpanBottom(t, _m) {
|
|
2734
|
+
return { left: t.right + BASE_SPACE, top: t.top };
|
|
2735
|
+
}
|
|
2736
|
+
// left span-bottom: to the left of trigger, top edge aligned with trigger top
|
|
2737
|
+
#leftSpanBottom(t, m) {
|
|
2738
|
+
return { left: t.left - m.width - BASE_SPACE, top: t.top };
|
|
2739
|
+
}
|
|
2740
|
+
// right center: to the right of trigger, vertically centered
|
|
2741
|
+
#rightCenter(t, m) {
|
|
2742
|
+
return { left: t.right + BASE_SPACE, top: t.top + t.height / 2 - m.height / 2 };
|
|
2743
|
+
}
|
|
2744
|
+
// left center: to the left of trigger, vertically centered
|
|
2745
|
+
#leftCenter(t, m) {
|
|
2746
|
+
return { left: t.left - m.width - BASE_SPACE, top: t.top + t.height / 2 - m.height / 2 };
|
|
2747
|
+
}
|
|
2748
|
+
// right span-top: to the right of trigger, bottom edge aligned with trigger bottom
|
|
2749
|
+
#rightSpanTop(t, m) {
|
|
2750
|
+
return { left: t.right + BASE_SPACE, top: t.bottom - m.height };
|
|
2751
|
+
}
|
|
2752
|
+
// left span-top: to the left of trigger, bottom edge aligned with trigger bottom
|
|
2753
|
+
#leftSpanTop(t, m) {
|
|
2754
|
+
return { left: t.left - m.width - BASE_SPACE, top: t.bottom - m.height };
|
|
2755
|
+
}
|
|
2756
|
+
/** Check if a position fits entirely within the viewport */
|
|
2757
|
+
#fitsInViewport(pos, m) {
|
|
2758
|
+
return (pos.left >= 0 &&
|
|
2759
|
+
pos.top >= 0 &&
|
|
2760
|
+
pos.left + m.width <= window.innerWidth &&
|
|
2761
|
+
pos.top + m.height <= window.innerHeight);
|
|
2762
|
+
}
|
|
2763
|
+
/** Clamp a position so the popover stays within the viewport */
|
|
2764
|
+
#clampToViewport(pos, m) {
|
|
2715
2765
|
return {
|
|
2716
|
-
left:
|
|
2717
|
-
top:
|
|
2718
|
-
};
|
|
2719
|
-
}
|
|
2720
|
-
#alignTopRight(triggerRect, menuRect) {
|
|
2721
|
-
const newLeft = triggerRect.right + BASE_SPACE;
|
|
2722
|
-
const newTop = triggerRect.top;
|
|
2723
|
-
return {
|
|
2724
|
-
left: newLeft,
|
|
2725
|
-
top: newTop,
|
|
2726
|
-
};
|
|
2727
|
-
}
|
|
2728
|
-
#alignBottomRight(triggerRect, menuRect) {
|
|
2729
|
-
const newLeft = triggerRect.right + BASE_SPACE;
|
|
2730
|
-
const newTop = triggerRect.bottom;
|
|
2731
|
-
return {
|
|
2732
|
-
left: newLeft,
|
|
2733
|
-
top: newTop,
|
|
2734
|
-
};
|
|
2735
|
-
}
|
|
2736
|
-
#alignLeftOver(triggerRect, menuRect) {
|
|
2737
|
-
const newLeft = triggerRect.left;
|
|
2738
|
-
const newTop = triggerRect.bottom - triggerRect.height - menuRect.height - BASE_SPACE;
|
|
2739
|
-
return {
|
|
2740
|
-
left: newLeft,
|
|
2741
|
-
top: newTop,
|
|
2766
|
+
left: Math.max(0, Math.min(pos.left, window.innerWidth - m.width)),
|
|
2767
|
+
top: Math.max(0, Math.min(pos.top, window.innerHeight - m.height)),
|
|
2742
2768
|
};
|
|
2743
2769
|
}
|
|
2744
2770
|
#calculateMenuPosition() {
|
|
2745
2771
|
const triggerRect = this.triggerRef()?.nativeElement.getBoundingClientRect();
|
|
2746
2772
|
const menuRect = this.popoverContentRef()?.nativeElement.getBoundingClientRect();
|
|
2747
|
-
|
|
2748
|
-
|
|
2773
|
+
if (!triggerRect || !menuRect)
|
|
2774
|
+
return;
|
|
2775
|
+
// Mirror the CSS position-try-fallbacks order
|
|
2776
|
+
const tryOrderDefault = [
|
|
2777
|
+
this.#bottomSpanRight,
|
|
2778
|
+
this.#topSpanRight,
|
|
2779
|
+
this.#bottomSpanLeft,
|
|
2780
|
+
this.#topSpanLeft,
|
|
2781
|
+
this.#rightSpanBottom,
|
|
2782
|
+
this.#leftSpanBottom,
|
|
2783
|
+
this.#rightCenter,
|
|
2784
|
+
this.#leftCenter,
|
|
2785
|
+
this.#rightSpanTop,
|
|
2786
|
+
this.#leftSpanTop,
|
|
2787
|
+
];
|
|
2788
|
+
const tryOrderMultiLayer = [
|
|
2789
|
+
this.#rightSpanBottom,
|
|
2790
|
+
this.#rightSpanTop,
|
|
2791
|
+
this.#leftSpanBottom,
|
|
2792
|
+
this.#leftSpanTop,
|
|
2793
|
+
this.#rightCenter,
|
|
2794
|
+
this.#leftCenter,
|
|
2795
|
+
this.#bottomSpanRight,
|
|
2796
|
+
this.#topSpanRight,
|
|
2797
|
+
this.#bottomSpanLeft,
|
|
2798
|
+
this.#topSpanLeft,
|
|
2799
|
+
];
|
|
2749
2800
|
const tryOrder = this.asMultiLayer() ? tryOrderMultiLayer : tryOrderDefault;
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
const
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
this.menuStyle.set({
|
|
2756
|
-
left: position.left + 'px',
|
|
2757
|
-
top: position.top + 'px',
|
|
2758
|
-
});
|
|
2801
|
+
// Try each position, use the first one that fits
|
|
2802
|
+
for (const positionFn of tryOrder) {
|
|
2803
|
+
const pos = positionFn.call(this, triggerRect, menuRect);
|
|
2804
|
+
if (this.#fitsInViewport(pos, menuRect)) {
|
|
2805
|
+
this.menuStyle.set({ left: pos.left + 'px', top: pos.top + 'px' });
|
|
2759
2806
|
return;
|
|
2760
2807
|
}
|
|
2761
2808
|
}
|
|
2762
|
-
|
|
2763
|
-
this.
|
|
2764
|
-
|
|
2765
|
-
top: fallbackPosition.top + 'px',
|
|
2766
|
-
});
|
|
2809
|
+
// If nothing fits perfectly, use the first position clamped to viewport
|
|
2810
|
+
const fallback = this.#clampToViewport(tryOrder[0].call(this, triggerRect, menuRect), menuRect);
|
|
2811
|
+
this.menuStyle.set({ left: fallback.left + 'px', top: fallback.top + 'px' });
|
|
2767
2812
|
}
|
|
2768
2813
|
ngOnDestroy() {
|
|
2769
2814
|
this.openAbort?.abort();
|
|
@@ -6408,7 +6453,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
6408
6453
|
class ShipToggleCard {
|
|
6409
6454
|
constructor() {
|
|
6410
6455
|
this.isActive = model(false, ...(ngDevMode ? [{ debugName: "isActive" }] : []));
|
|
6411
|
-
this.
|
|
6456
|
+
this.disableToggle = input(false, ...(ngDevMode ? [{ debugName: "disableToggle" }] : []));
|
|
6412
6457
|
this.color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : []));
|
|
6413
6458
|
this.variant = input(null, ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
6414
6459
|
this.hostClasses = shipComponentClasses('card', {
|
|
@@ -6416,20 +6461,15 @@ class ShipToggleCard {
|
|
|
6416
6461
|
variant: this.variant,
|
|
6417
6462
|
});
|
|
6418
6463
|
}
|
|
6419
|
-
ngOnInit() {
|
|
6420
|
-
if (this.disallowToggle()) {
|
|
6421
|
-
this.isActive.set(true);
|
|
6422
|
-
}
|
|
6423
|
-
}
|
|
6424
6464
|
toggle() {
|
|
6425
6465
|
this.isActive.set(!this.isActive());
|
|
6426
6466
|
}
|
|
6427
6467
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ShipToggleCard, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6428
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: ShipToggleCard, isStandalone: true, selector: "sh-toggle-card", inputs: { isActive: { classPropertyName: "isActive", publicName: "isActive", isSignal: true, isRequired: false, transformFunction: null },
|
|
6429
|
-
<h3 (click)="
|
|
6468
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: ShipToggleCard, isStandalone: true, selector: "sh-toggle-card", inputs: { isActive: { classPropertyName: "isActive", publicName: "isActive", isSignal: true, isRequired: false, transformFunction: null }, disableToggle: { classPropertyName: "disableToggle", publicName: "disableToggle", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isActive: "isActiveChange" }, host: { properties: { "class.active": "isActive()", "class": "hostClasses()" } }, ngImport: i0, template: `
|
|
6469
|
+
<h3 (click)="!disableToggle() && toggle()">
|
|
6430
6470
|
<ng-content select="[title]">Title</ng-content>
|
|
6431
6471
|
|
|
6432
|
-
@if (!
|
|
6472
|
+
@if (!disableToggle()) {
|
|
6433
6473
|
<sh-icon class="toggle-icon">caret-down</sh-icon>
|
|
6434
6474
|
}
|
|
6435
6475
|
</h3>
|
|
@@ -6447,10 +6487,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
6447
6487
|
selector: 'sh-toggle-card',
|
|
6448
6488
|
imports: [ShipIcon],
|
|
6449
6489
|
template: `
|
|
6450
|
-
<h3 (click)="
|
|
6490
|
+
<h3 (click)="!disableToggle() && toggle()">
|
|
6451
6491
|
<ng-content select="[title]">Title</ng-content>
|
|
6452
6492
|
|
|
6453
|
-
@if (!
|
|
6493
|
+
@if (!disableToggle()) {
|
|
6454
6494
|
<sh-icon class="toggle-icon">caret-down</sh-icon>
|
|
6455
6495
|
}
|
|
6456
6496
|
</h3>
|
|
@@ -6467,7 +6507,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
6467
6507
|
'[class]': 'hostClasses()',
|
|
6468
6508
|
},
|
|
6469
6509
|
}]
|
|
6470
|
-
}], propDecorators: { isActive: [{ type: i0.Input, args: [{ isSignal: true, alias: "isActive", required: false }] }, { type: i0.Output, args: ["isActiveChange"] }],
|
|
6510
|
+
}], propDecorators: { isActive: [{ type: i0.Input, args: [{ isSignal: true, alias: "isActive", required: false }] }, { type: i0.Output, args: ["isActiveChange"] }], disableToggle: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableToggle", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }] } });
|
|
6471
6511
|
|
|
6472
6512
|
class ShipToggle {
|
|
6473
6513
|
constructor() {
|