@ifsworld/granite-components 16.1.0-beta.1 → 16.1.0-beta.2
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.
|
@@ -689,20 +689,20 @@ function throwGraniteMenuMissingError() {
|
|
|
689
689
|
}
|
|
690
690
|
/**
|
|
691
691
|
* Throws an exception for the case when menu's x-position value isn't valid.
|
|
692
|
-
* In other words, it doesn't match 'before' or '
|
|
692
|
+
* In other words, it doesn't match 'before', 'after', or 'center'.
|
|
693
693
|
* @docs-private
|
|
694
694
|
*/
|
|
695
695
|
function throwGraniteMenuInvalidPositionX() {
|
|
696
|
-
throw Error(`xPosition value must be either 'before' or
|
|
696
|
+
throw Error(`xPosition value must be either 'before', 'after', or 'center'.
|
|
697
697
|
Example: <granite-menu xPosition="before" #menu="graniteMenu"></granite-menu>`);
|
|
698
698
|
}
|
|
699
699
|
/**
|
|
700
700
|
* Throws an exception for the case when menu's y-position value isn't valid.
|
|
701
|
-
* In other words, it doesn't match 'above' or '
|
|
701
|
+
* In other words, it doesn't match 'above', 'below', or 'center'.
|
|
702
702
|
* @docs-private
|
|
703
703
|
*/
|
|
704
704
|
function throwGraniteMenuInvalidPositionY() {
|
|
705
|
-
throw Error(`yPosition value must be either 'above' or
|
|
705
|
+
throw Error(`yPosition value must be either 'above', 'below', or 'center'.
|
|
706
706
|
Example: <granite-menu yPosition="above" #menu="graniteMenu"></granite-menu>`);
|
|
707
707
|
}
|
|
708
708
|
|
|
@@ -885,7 +885,7 @@ class _MenuBaseComponent {
|
|
|
885
885
|
return this._xPosition;
|
|
886
886
|
}
|
|
887
887
|
set xPosition(value) {
|
|
888
|
-
if (value !== 'before' && value !== 'after') {
|
|
888
|
+
if (value !== 'before' && value !== 'after' && value !== 'center') {
|
|
889
889
|
throwGraniteMenuInvalidPositionX();
|
|
890
890
|
}
|
|
891
891
|
this._xPosition = value;
|
|
@@ -895,7 +895,7 @@ class _MenuBaseComponent {
|
|
|
895
895
|
return this._yPosition;
|
|
896
896
|
}
|
|
897
897
|
set yPosition(value) {
|
|
898
|
-
if (value !== 'above' && value !== 'below') {
|
|
898
|
+
if (value !== 'above' && value !== 'below' && value !== 'center') {
|
|
899
899
|
throwGraniteMenuInvalidPositionY();
|
|
900
900
|
}
|
|
901
901
|
this._yPosition = value;
|
|
@@ -909,6 +909,13 @@ class _MenuBaseComponent {
|
|
|
909
909
|
}
|
|
910
910
|
constructor(_changeDetectorRef) {
|
|
911
911
|
this._changeDetectorRef = _changeDetectorRef;
|
|
912
|
+
/**
|
|
913
|
+
* Custom position configuration for the overlay.
|
|
914
|
+
* When provided, this overrides the default positioning logic based on
|
|
915
|
+
* xPosition and yPosition. Uses Angular CDK ConnectedPosition format.
|
|
916
|
+
* If empty or not provided, falls back to default positioning behavior.
|
|
917
|
+
*/
|
|
918
|
+
this.cdkConnectedOverlayPosition = [];
|
|
912
919
|
this.openOnHover = true;
|
|
913
920
|
this.scrollStrategy = 'reposition';
|
|
914
921
|
/**
|
|
@@ -1206,7 +1213,7 @@ class _MenuBaseComponent {
|
|
|
1206
1213
|
});
|
|
1207
1214
|
}
|
|
1208
1215
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: _MenuBaseComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1209
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: _MenuBaseComponent, isStandalone: true, inputs: { xPosition: "xPosition", yPosition: "yPosition", title: "title", closeLabel: "closeLabel", openOnHover: "openOnHover", scrollStrategy: "scrollStrategy", styles: "styles", touchStyles: "touchStyles", preventParentClose: "preventParentClose" }, outputs: { closed: "closed", opened: "opened" }, queries: [{ propertyName: "customTemplate", first: true, predicate: GraniteMenuCustomTemplateDirective, descendants: true }, { propertyName: "_allItems", predicate: GraniteMenuItemComponent, descendants: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 }); }
|
|
1216
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: _MenuBaseComponent, isStandalone: true, inputs: { xPosition: "xPosition", yPosition: "yPosition", cdkConnectedOverlayPosition: "cdkConnectedOverlayPosition", title: "title", closeLabel: "closeLabel", openOnHover: "openOnHover", scrollStrategy: "scrollStrategy", styles: "styles", touchStyles: "touchStyles", preventParentClose: "preventParentClose" }, outputs: { closed: "closed", opened: "opened" }, queries: [{ propertyName: "customTemplate", first: true, predicate: GraniteMenuCustomTemplateDirective, descendants: true }, { propertyName: "_allItems", predicate: GraniteMenuItemComponent, descendants: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 }); }
|
|
1210
1217
|
}
|
|
1211
1218
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: _MenuBaseComponent, decorators: [{
|
|
1212
1219
|
type: Directive
|
|
@@ -1214,6 +1221,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
|
|
|
1214
1221
|
type: Input
|
|
1215
1222
|
}], yPosition: [{
|
|
1216
1223
|
type: Input
|
|
1224
|
+
}], cdkConnectedOverlayPosition: [{
|
|
1225
|
+
type: Input
|
|
1217
1226
|
}], title: [{
|
|
1218
1227
|
type: Input
|
|
1219
1228
|
}], closeLabel: [{
|
|
@@ -1816,26 +1825,51 @@ class GraniteMenuTriggerForDirective {
|
|
|
1816
1825
|
* @param positionStrategy Strategy whose position to update.
|
|
1817
1826
|
*/
|
|
1818
1827
|
_setPosition(positionStrategy) {
|
|
1828
|
+
if (this.menu.cdkConnectedOverlayPosition &&
|
|
1829
|
+
this.menu.cdkConnectedOverlayPosition.length > 0) {
|
|
1830
|
+
positionStrategy.withPositions(this.menu.cdkConnectedOverlayPosition);
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1819
1833
|
const MENU_PANEL_TOP_PADDING = 0;
|
|
1820
|
-
let [originX, originFallbackX] = this.menu.xPosition === 'before'
|
|
1821
|
-
|
|
1834
|
+
let [originX, originFallbackX] = this.menu.xPosition === 'before'
|
|
1835
|
+
? ['end', 'start']
|
|
1836
|
+
: this.menu.xPosition === 'center'
|
|
1837
|
+
? ['center', 'center']
|
|
1838
|
+
: ['start', 'end'];
|
|
1839
|
+
const [overlayY, overlayFallbackY] = this.menu.yPosition === 'above'
|
|
1840
|
+
? ['bottom', 'top']
|
|
1841
|
+
: this.menu.yPosition === 'center'
|
|
1842
|
+
? ['center', 'center']
|
|
1843
|
+
: ['top', 'bottom'];
|
|
1822
1844
|
let [originY, originFallbackY] = [overlayY, overlayFallbackY];
|
|
1823
1845
|
let [overlayX, overlayFallbackX] = [originX, originFallbackX];
|
|
1824
1846
|
let offsetY = 0;
|
|
1825
1847
|
if (this.triggersSubmenu()) {
|
|
1826
1848
|
// When the menu is a sub-menu, it should always align itself
|
|
1827
1849
|
// to the edges of the trigger, instead of overlapping it.
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1850
|
+
if (this.menu.xPosition === 'center') {
|
|
1851
|
+
overlayFallbackX = originX = 'center';
|
|
1852
|
+
originFallbackX = overlayX = 'center';
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
overlayFallbackX = originX =
|
|
1856
|
+
this.menu.xPosition === 'before' ? 'start' : 'end';
|
|
1857
|
+
originFallbackX = overlayX = originX === 'end' ? 'start' : 'end';
|
|
1858
|
+
}
|
|
1831
1859
|
offsetY =
|
|
1832
1860
|
overlayY === 'bottom'
|
|
1833
1861
|
? MENU_PANEL_TOP_PADDING
|
|
1834
1862
|
: -MENU_PANEL_TOP_PADDING;
|
|
1835
1863
|
}
|
|
1836
1864
|
else {
|
|
1837
|
-
|
|
1838
|
-
|
|
1865
|
+
if (this.menu.yPosition === 'center') {
|
|
1866
|
+
originY = 'center';
|
|
1867
|
+
originFallbackY = 'center';
|
|
1868
|
+
}
|
|
1869
|
+
else {
|
|
1870
|
+
originY = overlayY === 'top' ? 'bottom' : 'top';
|
|
1871
|
+
originFallbackY = overlayFallbackY === 'top' ? 'bottom' : 'top';
|
|
1872
|
+
}
|
|
1839
1873
|
}
|
|
1840
1874
|
positionStrategy.withPositions([
|
|
1841
1875
|
{ originX, originY, overlayX, overlayY, offsetY },
|