@moni-labs/moni-ui 0.4.14 → 0.4.17
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/custom-elements.json +10 -0
- package/dist/browser/moni-ui.iife.min.js +6 -1
- package/dist/browser/moni-ui.iife.min.js.br +0 -0
- package/dist/browser/moni-ui.iife.min.js.gz +0 -0
- package/dist/browser/moni-ui.iife.min.js.map +1 -1
- package/dist/browser/moni-ui.min.js +75 -23
- package/dist/browser/moni-ui.min.js.br +0 -0
- package/dist/browser/moni-ui.min.js.gz +0 -0
- package/dist/browser/moni-ui.min.js.map +1 -1
- package/dist/cdn/components/moni-bottom-sheet.js +6 -1
- package/dist/cdn/importmap.json +98 -98
- package/dist/components/moni-bottom-sheet.d.ts +19 -5
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
- package/dist/components/moni-bottom-sheet.js +169 -30
- package/docs/api.json +13 -2
- package/docs/assets/moni-color-field/shape--square.png +0 -0
- package/docs/assets/moni-file-field/shape--square.png +0 -0
- package/docs/components/bottom-sheet.md +2 -1
- package/package.json +1 -1
- package/src/components/moni-bottom-sheet.test.ts +393 -0
- package/src/components/moni-bottom-sheet.ts +175 -29
package/custom-elements.json
CHANGED
|
@@ -373,6 +373,16 @@
|
|
|
373
373
|
},
|
|
374
374
|
"default": "''",
|
|
375
375
|
"description": "Restricción opcional de inline-size (ancho) máximo para la hoja.\n\nCuando se establece (ej. `'640px'`), la hoja no excederá este ancho incluso en\npantallas anchas. Útil para puntos de interrupción de tableta/escritorio donde se prefiere\nun modal centrado en lugar de una hoja de ancho completo."
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"kind": "method",
|
|
379
|
+
"name": "show",
|
|
380
|
+
"description": "Abre el bottom sheet."
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"kind": "method",
|
|
384
|
+
"name": "close",
|
|
385
|
+
"description": "Cierra el bottom sheet ejecutando la animación fluida hacia abajo."
|
|
376
386
|
}
|
|
377
387
|
],
|
|
378
388
|
"events": [],
|
|
@@ -1093,7 +1093,7 @@ var MoniUI=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modul
|
|
|
1093
1093
|
.badge.min { clip-path: circle(18.75% at 50% 50%); }
|
|
1094
1094
|
`]}render(){return z`<span class=${[`badge`,this.position||``,this.shape||``,this.inline?`none`:``].filter(Boolean).join(` `)} part="badge">
|
|
1095
1095
|
<slot>${this.value}</slot>
|
|
1096
|
-
</span>`}};K([H({reflect:!0})],qe.prototype,`value`,void 0),K([H({reflect:!0})],qe.prototype,`position`,void 0),K([H({reflect:!0})],qe.prototype,`shape`,void 0),K([H({reflect:!0})],qe.prototype,`color`,void 0),K([H({type:Boolean,reflect:!0})],qe.prototype,`inline`,void 0),K([H({type:Boolean,reflect:!0})],qe.prototype,`border`,void 0),qe=K([V(`moni-badge`)],qe);function Je(e,t,n){let r=new CustomEvent(t,{bubbles:n?.bubbles??!0,composed:n?.composed??!0,cancelable:n?.cancelable??!1,detail:n?.detail??{}});return e.dispatchEvent(r)}var Ye=class extends W{constructor(...e){super(...e),this.open=!1,this.size=`medium`,this.modal=!0,this.title=``,this.handle=!1,this.positioning=`fixed`,this.expandedHeight=`85%`,this.maxWidth=``,this._originalParent=null,this._originalSibling=null,this._isDragging=!1,this._startY=0,this.
|
|
1096
|
+
</span>`}};K([H({reflect:!0})],qe.prototype,`value`,void 0),K([H({reflect:!0})],qe.prototype,`position`,void 0),K([H({reflect:!0})],qe.prototype,`shape`,void 0),K([H({reflect:!0})],qe.prototype,`color`,void 0),K([H({type:Boolean,reflect:!0})],qe.prototype,`inline`,void 0),K([H({type:Boolean,reflect:!0})],qe.prototype,`border`,void 0),qe=K([V(`moni-badge`)],qe);function Je(e,t,n){let r=new CustomEvent(t,{bubbles:n?.bubbles??!0,composed:n?.composed??!0,cancelable:n?.cancelable??!1,detail:n?.detail??{}});return e.dispatchEvent(r)}var Ye=class extends W{constructor(...e){super(...e),this.open=!1,this.size=`medium`,this.modal=!0,this.title=``,this.handle=!1,this.positioning=`fixed`,this.expandedHeight=`85%`,this.maxWidth=``,this._originalParent=null,this._originalSibling=null,this._isDragging=!1,this._startY=0,this._lastDeltaY=0,this._sheetHeight=0,this._defaultHeight=0,this._justDragged=!1,this._skipRequestClose=!1,this._isClosing=!1}show(){this._isClosing=!1,this._isDragging=!1,this._lastDeltaY=0,this._dialog&&(this._dialog.classList.remove(`dragging`,`expanded`),this._dialog.style.transform=``,this._dialog.style.height=``),this.open=!0}close(){return this._animateAndClose()}willUpdate(e){e.has(`open`)&&this.open!==e.get(`open`)&&(this.open?Je(this,`moni-request-open`,{cancelable:!0})||(this.open=!1):this._skipRequestClose||Je(this,`moni-request-close`,{cancelable:!0})||(this.open=!0))}async _animateAndClose(){if(this._isClosing||!this.open)return!1;this._isClosing=!0,this._skipRequestClose=!0;let e=Je(this,`moni-request-close`,{cancelable:!0});return this._skipRequestClose=!1,e?(Je(this,`moni-close`),this._dialog.classList.remove(`expanded`),this._dialog.style.transform=`translateY(100%)`,this._dialog.style.height=``,await new Promise(e=>{let t=()=>{this._dialog.removeEventListener(`transitionend`,t),e(null)};this._dialog.addEventListener(`transitionend`,t),setTimeout(t,300)}),this._isClosing=!1,this._isDragging=!1,this._lastDeltaY=0,this._dialog&&(this._dialog.classList.remove(`dragging`,`expanded`),this._dialog.style.transform=``,this._dialog.style.height=``),this._skipRequestClose=!0,this.open=!1,this._skipRequestClose=!1,this.dispatchEvent(new Event(`close`,{bubbles:!0,composed:!0})),Je(this,`moni-closed`),!0):(this._isClosing=!1,!1)}_getMaxHeightPx(){let e=this.expandedHeight||`85%`;return e.endsWith(`%`)||e.endsWith(`vh`)?window.innerHeight*(parseFloat(e)/100):e.endsWith(`px`)?parseFloat(e):window.innerHeight*.85}_onPointerDown(e){let t=e.target;if(!(!t.closest(`.handle`)&&!t.closest(`header`))){this._isDragging=!0,this._startY=e.clientY,this._sheetHeight=this._dialog.getBoundingClientRect().height,this._lastDeltaY=0,this._dialog.classList.contains(`expanded`)?this._defaultHeight||=Math.min(this._sheetHeight*.6,384):this._defaultHeight=this._sheetHeight;try{t.setPointerCapture(e.pointerId)}catch{}this._dialog.classList.add(`dragging`)}}_onPointerMove(e){if(!this._isDragging)return;let t=e.clientY-this._startY;this._lastDeltaY=t;let n=this._dialog.classList.contains(`expanded`),r=this._getMaxHeightPx();if(n){if(t>0){let e=this._sheetHeight-t;this._dialog.style.transform=``,this._dialog.style.height=`${Math.max(0,e)}px`}else{let e=this._sheetHeight-t*.2;this._dialog.style.transform=``,this._dialog.style.height=`${Math.min(r,e)}px`}}else if(t>0)this._dialog.style.transform=`translateY(${t}px)`,this._dialog.style.height=``;else{let e=this._sheetHeight-t;this._dialog.style.transform=``,this._dialog.style.height=`${Math.min(r,e)}px`}}_onPointerUp(e){if(!this._isDragging)return;let t=e.target;try{t&&t.hasPointerCapture?.(e.pointerId)&&t.releasePointerCapture(e.pointerId)}catch{}this._isDragging=!1,this._dialog.classList.remove(`dragging`);let n=typeof e.clientY==`number`&&e.clientY>0,r=n?e.clientY-this._startY:this._lastDeltaY;Math.abs(r)>5&&(this._justDragged=!0,setTimeout(()=>{this._justDragged=!1},50));let i=this._dialog.classList.contains(`expanded`),a=this._getMaxHeightPx(),o=this._defaultHeight||this._sheetHeight*.6||300,s=n&&typeof window<`u`&&e.clientY>=window.innerHeight-30;if(i){let e=this._sheetHeight-r;s||r>this._sheetHeight*.4||e<o-80||e<100?this._animateAndClose().then(e=>{e||(this._dialog.style.transform=``,this._dialog.style.height=``)}):e<(a+o)/2?(this._dialog.classList.remove(`expanded`),this._dialog.style.transform=``,this._dialog.style.height=``):(this._dialog.style.transform=``,this._dialog.style.height=``)}else if(r<0&&!s)this._sheetHeight-r>this._sheetHeight+80&&this._dialog.classList.add(`expanded`),this._dialog.style.transform=``,this._dialog.style.height=``;else{let e=Math.min(80,this._sheetHeight*.25);s||r>e?this._animateAndClose().then(e=>{e||(this._dialog.style.transform=``)}):this._dialog.style.transform=``}this._lastDeltaY=0}_onPointerCancel(e){this._isDragging&&this._onPointerUp(e)}_onLostPointerCapture(e){this._isDragging&&this._onPointerUp(e)}_onDialogClick(e){if(this._justDragged){this._justDragged=!1;return}this.modal&&e.target===this._dialog&&this._animateAndClose()}updated(e){if(super.updated(e),e.has(`expandedHeight`)&&this.style.setProperty(`--moni-bottom-sheet-expanded-height`,this.expandedHeight),e.has(`maxWidth`)&&this.style.setProperty(`--moni-bottom-sheet-max-width`,this.maxWidth||`100%`),e.has(`open`)&&(this.open?(this._isClosing=!1,this._isDragging=!1,this._lastDeltaY=0,this._dialog&&(this._dialog.classList.remove(`dragging`,`expanded`),this._dialog.style.transform=``,this._dialog.style.height=``),e.get(`open`)!==void 0&&Je(this,`moni-open`),this.positioning===`body`&&this.parentNode!==document.body&&(this._originalParent=this.parentNode,this._originalSibling=this.nextSibling,document.body.appendChild(this)),e.get(`open`)!==void 0&&setTimeout(()=>Je(this,`moni-opened`),300)):(this._isClosing=!1,this._isDragging=!1,this._lastDeltaY=0,this._dialog&&(this._dialog.classList.remove(`expanded`,`dragging`),this._dialog.style.transform=``,this._dialog.style.height=``),this.positioning===`body`&&this._originalParent&&this.parentNode===document.body&&(this._originalParent.insertBefore(this,this._originalSibling),this._originalParent=null,this._originalSibling=null)),this._dialog)){let e=this._dialog;if(this.open){if(this.modal&&typeof e.showModal==`function`){let t=!1;try{t=this._dialog.matches(`:modal`)}catch{t=!1}if(!t)try{e.showModal()}catch{}}else if(!this.modal&&typeof e.show==`function`)try{e.show()}catch{}else(this.modal&&typeof e.showModal!=`function`||!this.modal&&typeof e.show!=`function`)&&(this._dialog.open=!0)}else if(typeof e.close==`function`)try{e.close()}catch{}}}disconnectedCallback(){super.disconnectedCallback(),this.parentNode===document.body&&this.positioning===`body`&&this._originalParent&&this._originalParent.insertBefore(this,this._originalSibling)}static{this.styles=[G,g`
|
|
1097
1097
|
:host {
|
|
1098
1098
|
display: contents;
|
|
1099
1099
|
}
|
|
@@ -1131,6 +1131,10 @@ var MoniUI=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modul
|
|
|
1131
1131
|
transform: translateY(0);
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
+
dialog::backdrop {
|
|
1135
|
+
background-color: rgb(0 0 0 / 0.5);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1134
1138
|
dialog.fixed {
|
|
1135
1139
|
position: fixed;
|
|
1136
1140
|
inset: auto 0 0 0;
|
|
@@ -1228,6 +1232,7 @@ var MoniUI=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modul
|
|
|
1228
1232
|
@pointermove=${this._onPointerMove}
|
|
1229
1233
|
@pointerup=${this._onPointerUp}
|
|
1230
1234
|
@pointercancel=${this._onPointerCancel}
|
|
1235
|
+
@lostpointercapture=${this._onLostPointerCapture}
|
|
1231
1236
|
>
|
|
1232
1237
|
${this.handle?z`<div class="handle" aria-hidden="true"></div>`:B}
|
|
1233
1238
|
<header part="header">
|
|
Binary file
|
|
Binary file
|