@waggylabs/yumekit 0.4.2-beta.27 → 0.4.2-beta.30

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.
@@ -130,6 +130,7 @@ export class YumeDate extends HTMLElement {
130
130
  * @param {HTMLElement} picker
131
131
  */
132
132
  _handleRangeTypeahead(text: string, picker: HTMLElement): void;
133
+ _positionPopup(popup: any, trigger: any): void;
133
134
  /**
134
135
  * Parse partial user input and return an object with whatever date parts
135
136
  * could be extracted based on the format string. Returns null if nothing
@@ -3827,6 +3827,36 @@ class YumeDate extends HTMLElement {
3827
3827
  this.render();
3828
3828
  }
3829
3829
 
3830
+ _positionPopup(popup, trigger) {
3831
+ const triggerRect = trigger.getBoundingClientRect();
3832
+ const popupWidth = popup.offsetWidth;
3833
+ const popupHeight = popup.offsetHeight;
3834
+ const gap = 4;
3835
+ const vw = window.innerWidth;
3836
+ const vh = window.innerHeight;
3837
+
3838
+ // Vertical: prefer below; flip above when not enough space below and more space above
3839
+ const spaceBelow = vh - triggerRect.bottom - gap;
3840
+ const spaceAbove = triggerRect.top - gap;
3841
+ if (spaceBelow >= popupHeight || spaceBelow >= spaceAbove) {
3842
+ popup.style.top = `calc(100% + ${gap}px)`;
3843
+ popup.style.bottom = "auto";
3844
+ } else {
3845
+ popup.style.top = "auto";
3846
+ popup.style.bottom = `calc(100% + ${gap}px)`;
3847
+ }
3848
+
3849
+ // Horizontal: prefer left-aligned; flip to right-aligned when popup overflows viewport
3850
+ const spaceRight = vw - triggerRect.left;
3851
+ if (spaceRight >= popupWidth) {
3852
+ popup.style.left = "0";
3853
+ popup.style.right = "auto";
3854
+ } else {
3855
+ popup.style.left = "auto";
3856
+ popup.style.right = "0";
3857
+ }
3858
+ }
3859
+
3830
3860
  /**
3831
3861
  * Parse partial user input and return an object with whatever date parts
3832
3862
  * could be extracted based on the format string. Returns null if nothing
@@ -4117,7 +4147,10 @@ class YumeDate extends HTMLElement {
4117
4147
  if (!popup || !trigger) return;
4118
4148
  popup.hidden = !open;
4119
4149
  trigger.setAttribute("aria-expanded", String(open));
4120
- if (open) this._selectedParts.clear();
4150
+ if (open) {
4151
+ this._selectedParts.clear();
4152
+ this._positionPopup(popup, trigger);
4153
+ }
4121
4154
  }
4122
4155
 
4123
4156
  _setupMediaQuery() {
@@ -167,6 +167,7 @@ class YumeTheme extends HTMLElement {
167
167
  font-family: var(--font-family-body, sans-serif);
168
168
  color: var(--base-content--, inherit);
169
169
  font-weight: var(--font-weight-body, 400);
170
+ background: var(--base-background-app, transparent);
170
171
  }`;
171
172
  this.shadowRoot.appendChild(baseStyle);
172
173
 
package/dist/index.js CHANGED
@@ -6362,6 +6362,36 @@ class YumeDate extends HTMLElement {
6362
6362
  this.render();
6363
6363
  }
6364
6364
 
6365
+ _positionPopup(popup, trigger) {
6366
+ const triggerRect = trigger.getBoundingClientRect();
6367
+ const popupWidth = popup.offsetWidth;
6368
+ const popupHeight = popup.offsetHeight;
6369
+ const gap = 4;
6370
+ const vw = window.innerWidth;
6371
+ const vh = window.innerHeight;
6372
+
6373
+ // Vertical: prefer below; flip above when not enough space below and more space above
6374
+ const spaceBelow = vh - triggerRect.bottom - gap;
6375
+ const spaceAbove = triggerRect.top - gap;
6376
+ if (spaceBelow >= popupHeight || spaceBelow >= spaceAbove) {
6377
+ popup.style.top = `calc(100% + ${gap}px)`;
6378
+ popup.style.bottom = "auto";
6379
+ } else {
6380
+ popup.style.top = "auto";
6381
+ popup.style.bottom = `calc(100% + ${gap}px)`;
6382
+ }
6383
+
6384
+ // Horizontal: prefer left-aligned; flip to right-aligned when popup overflows viewport
6385
+ const spaceRight = vw - triggerRect.left;
6386
+ if (spaceRight >= popupWidth) {
6387
+ popup.style.left = "0";
6388
+ popup.style.right = "auto";
6389
+ } else {
6390
+ popup.style.left = "auto";
6391
+ popup.style.right = "0";
6392
+ }
6393
+ }
6394
+
6365
6395
  /**
6366
6396
  * Parse partial user input and return an object with whatever date parts
6367
6397
  * could be extracted based on the format string. Returns null if nothing
@@ -6652,7 +6682,10 @@ class YumeDate extends HTMLElement {
6652
6682
  if (!popup || !trigger) return;
6653
6683
  popup.hidden = !open;
6654
6684
  trigger.setAttribute("aria-expanded", String(open));
6655
- if (open) this._selectedParts.clear();
6685
+ if (open) {
6686
+ this._selectedParts.clear();
6687
+ this._positionPopup(popup, trigger);
6688
+ }
6656
6689
  }
6657
6690
 
6658
6691
  _setupMediaQuery() {
@@ -11547,6 +11580,7 @@ class YumeTheme extends HTMLElement {
11547
11580
  font-family: var(--font-family-body, sans-serif);
11548
11581
  color: var(--base-content--, inherit);
11549
11582
  font-weight: var(--font-weight-body, 400);
11583
+ background: var(--base-background-app, transparent);
11550
11584
  }`;
11551
11585
  this.shadowRoot.appendChild(baseStyle);
11552
11586