@moni-labs/moni-ui 0.4.7 → 0.4.8

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.
@@ -117,6 +117,32 @@ describe('moni-morph-modal', () => {
117
117
  expect(el.hasAttribute('open')).toBe(true);
118
118
  });
119
119
 
120
+ it('ocupa todo el viewport cuando fullscreen está activo', async () => {
121
+ el.fullscreen = true;
122
+ await el.updateComplete;
123
+ const rect = (el as unknown as { _computeFinalRect: (target: DOMRect) => DOMRect })
124
+ ._computeFinalRect(new DOMRect(24, 700, 56, 56));
125
+
126
+ expect(el.hasAttribute('fullscreen')).toBe(true);
127
+ expect(rect.x).toBe(0);
128
+ expect(rect.y).toBe(0);
129
+ expect(rect.width).toBe(window.innerWidth);
130
+ expect(rect.height).toBe(window.innerHeight);
131
+ expect(el.shadowRoot?.querySelector('.panel')?.classList.contains('fullscreen')).toBe(true);
132
+ });
133
+
134
+ it('aplica fullscreen responsive sólo bajo el breakpoint', () => {
135
+ el.responsiveFullscreen = true;
136
+ el.fullscreenBreakpoint = 600;
137
+ const usesFullscreen = () => (el as unknown as { _usesFullscreen: () => boolean })._usesFullscreen();
138
+
139
+ vi.stubGlobal('innerWidth', 480);
140
+ expect(usesFullscreen()).toBe(true);
141
+ vi.stubGlobal('innerWidth', 900);
142
+ expect(usesFullscreen()).toBe(false);
143
+ vi.unstubAllGlobals();
144
+ });
145
+
120
146
  it('proyecta el contenido del slot por defecto', async () => {
121
147
  const content = document.createElement('p');
122
148
  content.textContent = 'Hello';
@@ -229,6 +229,18 @@ export class MoniMorphModal extends MoniElement {
229
229
  @property({ type: Boolean, reflect: true, attribute: 'auto-size', converter: litBool })
230
230
  autoSize = false;
231
231
 
232
+ /** Fuerza al modal expandido a ocupar todo el viewport. */
233
+ @property({ type: Boolean, reflect: true, converter: litBool })
234
+ fullscreen = false;
235
+
236
+ /** Activa fullscreen únicamente cuando el viewport no supera el breakpoint configurado. */
237
+ @property({ type: Boolean, reflect: true, attribute: 'responsive-fullscreen', converter: litBool })
238
+ responsiveFullscreen = false;
239
+
240
+ /** Ancho máximo del viewport, en píxeles, para aplicar responsive-fullscreen. */
241
+ @property({ type: Number, reflect: true, attribute: 'fullscreen-breakpoint' })
242
+ fullscreenBreakpoint = 600;
243
+
232
244
  /**
233
245
  * Si es true, aplica un efecto de desenfoque (blur) al contenido durante la animación de entrada y salida.
234
246
  * @type {boolean}
@@ -1896,9 +1908,15 @@ export class MoniMorphModal extends MoniElement {
1896
1908
  el.style.height = `${rect.height}px`;
1897
1909
  }
1898
1910
 
1911
+ private _usesFullscreen(): boolean {
1912
+ if (this.fullscreen) return true;
1913
+ return this.responsiveFullscreen && typeof window !== 'undefined' && window.innerWidth <= this.fullscreenBreakpoint;
1914
+ }
1915
+
1899
1916
  private _computeFinalRect(targetRect: DOMRect, naturalSize?: { width: number; height: number }): DOMRect {
1900
1917
  const vw = window.innerWidth;
1901
1918
  const vh = window.innerHeight;
1919
+ if (this._usesFullscreen()) return new DOMRect(0, 0, vw, vh);
1902
1920
  const padding = 16;
1903
1921
 
1904
1922
  let width = this.autoSize && naturalSize ? naturalSize.width : this._parseSize(this.expandedWidth, vw);
@@ -2082,6 +2100,19 @@ export class MoniMorphModal extends MoniElement {
2082
2100
  z-index: var(--_z-index, 100);
2083
2101
  }
2084
2102
 
2103
+ .panel.fullscreen {
2104
+ border-radius: 0;
2105
+ box-shadow: none;
2106
+ }
2107
+
2108
+ .panel.fullscreen header {
2109
+ padding-block-start: max(1.25rem, env(safe-area-inset-top));
2110
+ }
2111
+
2112
+ .panel.fullscreen footer {
2113
+ padding-block-end: max(1.5rem, env(safe-area-inset-bottom));
2114
+ }
2115
+
2085
2116
  .panel-inner {
2086
2117
  display: flex;
2087
2118
  flex-direction: column;
@@ -2191,6 +2222,7 @@ export class MoniMorphModal extends MoniElement {
2191
2222
  override render() {
2192
2223
  const visible = this._visible || this.open;
2193
2224
  const headerEmpty = !this._hasHeader && !this.showCloseButton;
2225
+ const fullscreen = this._usesFullscreen();
2194
2226
  return html`
2195
2227
  ${this.hasBackdrop ? html`
2196
2228
  <div
@@ -2199,7 +2231,7 @@ export class MoniMorphModal extends MoniElement {
2199
2231
  style="${!this.modal ? 'background-color: transparent;' : ''}"
2200
2232
  ></div>
2201
2233
  ` : ''}
2202
- <div class="panel" part="panel">
2234
+ <div class="panel ${fullscreen ? 'fullscreen' : ''}" part="panel">
2203
2235
  <div class="panel-inner" part="panel-inner">
2204
2236
  <header
2205
2237
  class="${headerEmpty ? 'is-empty' : ''}"