@moni-labs/moni-ui 0.4.14 → 0.4.16
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 +2 -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 +51 -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 +2 -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 +111 -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 +331 -0
- package/src/components/moni-bottom-sheet.ts +117 -29
|
@@ -1845,23 +1845,30 @@ function qe(e, t, n) {
|
|
|
1845
1845
|
//#region src/components/moni-bottom-sheet.ts
|
|
1846
1846
|
var Je = class extends W {
|
|
1847
1847
|
constructor(...e) {
|
|
1848
|
-
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.
|
|
1848
|
+
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;
|
|
1849
|
+
}
|
|
1850
|
+
show() {
|
|
1851
|
+
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;
|
|
1852
|
+
}
|
|
1853
|
+
close() {
|
|
1854
|
+
return this._animateAndClose();
|
|
1849
1855
|
}
|
|
1850
1856
|
willUpdate(e) {
|
|
1851
1857
|
e.has("open") && this.open !== e.get("open") && (this.open ? qe(this, "moni-request-open", { cancelable: !0 }) || (this.open = !1) : this._skipRequestClose || qe(this, "moni-request-close", { cancelable: !0 }) || (this.open = !0));
|
|
1852
1858
|
}
|
|
1853
1859
|
async _animateAndClose() {
|
|
1854
|
-
this.
|
|
1860
|
+
if (this._isClosing || !this.open) return !1;
|
|
1861
|
+
this._isClosing = !0, this._skipRequestClose = !0;
|
|
1855
1862
|
let e = qe(this, "moni-request-close", { cancelable: !0 });
|
|
1856
|
-
return this._skipRequestClose = !1, e ? (this.
|
|
1857
|
-
bubbles: !0,
|
|
1858
|
-
composed: !0
|
|
1859
|
-
})), qe(this, "moni-close"), this._dialog.classList.remove("expanded"), this._dialog.style.transform = "translateY(100%)", this._dialog.style.height = "", await new Promise((e) => {
|
|
1863
|
+
return this._skipRequestClose = !1, e ? (qe(this, "moni-close"), this._dialog.classList.remove("expanded"), this._dialog.style.transform = "translateY(100%)", this._dialog.style.height = "", await new Promise((e) => {
|
|
1860
1864
|
let t = () => {
|
|
1861
1865
|
this._dialog.removeEventListener("transitionend", t), e(null);
|
|
1862
1866
|
};
|
|
1863
1867
|
this._dialog.addEventListener("transitionend", t), setTimeout(t, 300);
|
|
1864
|
-
}), this._dialog.style.transform = "", this._skipRequestClose = !0, this.open = !1, this._skipRequestClose = !1,
|
|
1868
|
+
}), 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", {
|
|
1869
|
+
bubbles: !0,
|
|
1870
|
+
composed: !0
|
|
1871
|
+
})), qe(this, "moni-closed"), !0) : (this._isClosing = !1, !1);
|
|
1865
1872
|
}
|
|
1866
1873
|
_getMaxHeightPx() {
|
|
1867
1874
|
let e = this.expandedHeight || "85%";
|
|
@@ -1869,11 +1876,19 @@ var Je = class extends W {
|
|
|
1869
1876
|
}
|
|
1870
1877
|
_onPointerDown(e) {
|
|
1871
1878
|
let t = e.target;
|
|
1872
|
-
!t.closest(".handle") && !t.closest("header")
|
|
1879
|
+
if (!(!t.closest(".handle") && !t.closest("header"))) {
|
|
1880
|
+
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;
|
|
1881
|
+
try {
|
|
1882
|
+
t.setPointerCapture(e.pointerId);
|
|
1883
|
+
} catch {}
|
|
1884
|
+
this._dialog.classList.add("dragging");
|
|
1885
|
+
}
|
|
1873
1886
|
}
|
|
1874
1887
|
_onPointerMove(e) {
|
|
1875
1888
|
if (!this._isDragging) return;
|
|
1876
|
-
let t = e.clientY - this._startY
|
|
1889
|
+
let t = e.clientY - this._startY;
|
|
1890
|
+
this._lastDeltaY = t;
|
|
1891
|
+
let n = this._dialog.classList.contains("expanded"), r = this._getMaxHeightPx();
|
|
1877
1892
|
if (n) {
|
|
1878
1893
|
if (t > 0) {
|
|
1879
1894
|
let e = this._sheetHeight - t;
|
|
@@ -1882,7 +1897,7 @@ var Je = class extends W {
|
|
|
1882
1897
|
let e = this._sheetHeight - t * .2;
|
|
1883
1898
|
this._dialog.style.transform = "", this._dialog.style.height = `${Math.min(r, e)}px`;
|
|
1884
1899
|
}
|
|
1885
|
-
} else if (t > 0) this.
|
|
1900
|
+
} else if (t > 0) this._dialog.style.transform = `translateY(${t}px)`, this._dialog.style.height = "";
|
|
1886
1901
|
else {
|
|
1887
1902
|
let e = this._sheetHeight - t;
|
|
1888
1903
|
this._dialog.style.transform = "", this._dialog.style.height = `${Math.min(r, e)}px`;
|
|
@@ -1890,23 +1905,35 @@ var Je = class extends W {
|
|
|
1890
1905
|
}
|
|
1891
1906
|
_onPointerUp(e) {
|
|
1892
1907
|
if (!this._isDragging) return;
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1908
|
+
let t = e.target;
|
|
1909
|
+
try {
|
|
1910
|
+
t && t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId);
|
|
1911
|
+
} catch {}
|
|
1912
|
+
this._isDragging = !1, this._dialog.classList.remove("dragging");
|
|
1913
|
+
let n = typeof e.clientY == "number" && e.clientY > 0, r = n ? e.clientY - this._startY : this._lastDeltaY;
|
|
1914
|
+
Math.abs(r) > 5 && (this._justDragged = !0, setTimeout(() => {
|
|
1896
1915
|
this._justDragged = !1;
|
|
1897
1916
|
}, 50));
|
|
1898
|
-
let
|
|
1899
|
-
if (
|
|
1900
|
-
let e = this._sheetHeight -
|
|
1901
|
-
|
|
1917
|
+
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;
|
|
1918
|
+
if (i) {
|
|
1919
|
+
let e = this._sheetHeight - r;
|
|
1920
|
+
s || r > this._sheetHeight * .4 || e < o - 80 || e < 100 ? this._animateAndClose().then((e) => {
|
|
1902
1921
|
e || (this._dialog.style.transform = "", this._dialog.style.height = "");
|
|
1903
|
-
}) : e < (
|
|
1904
|
-
} else
|
|
1905
|
-
|
|
1906
|
-
|
|
1922
|
+
}) : 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 = "");
|
|
1923
|
+
} else if (r < 0 && !s) this._sheetHeight - r > this._sheetHeight + 80 && this._dialog.classList.add("expanded"), this._dialog.style.transform = "", this._dialog.style.height = "";
|
|
1924
|
+
else {
|
|
1925
|
+
let e = Math.min(80, this._sheetHeight * .25);
|
|
1926
|
+
s || r > e ? this._animateAndClose().then((e) => {
|
|
1927
|
+
e || (this._dialog.style.transform = "");
|
|
1928
|
+
}) : this._dialog.style.transform = "";
|
|
1929
|
+
}
|
|
1930
|
+
this._lastDeltaY = 0;
|
|
1907
1931
|
}
|
|
1908
1932
|
_onPointerCancel(e) {
|
|
1909
|
-
this._isDragging &&
|
|
1933
|
+
this._isDragging && this._onPointerUp(e);
|
|
1934
|
+
}
|
|
1935
|
+
_onLostPointerCapture(e) {
|
|
1936
|
+
this._isDragging && this._onPointerUp(e);
|
|
1910
1937
|
}
|
|
1911
1938
|
_onDialogClick(e) {
|
|
1912
1939
|
if (this._justDragged) {
|
|
@@ -1916,7 +1943,7 @@ var Je = class extends W {
|
|
|
1916
1943
|
this.modal && e.target === this._dialog && this._animateAndClose();
|
|
1917
1944
|
}
|
|
1918
1945
|
updated(e) {
|
|
1919
|
-
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 ? (e.get("open") !== void 0 && qe(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(() => qe(this, "moni-opened"), 300)) : (this._dialog && this._dialog.classList.remove("expanded"), this.positioning === "body" && this._originalParent && this.parentNode === document.body && (this._originalParent.insertBefore(this, this._originalSibling), this._originalParent = null, this._originalSibling = null)));
|
|
1946
|
+
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 && qe(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(() => qe(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)));
|
|
1920
1947
|
}
|
|
1921
1948
|
disconnectedCallback() {
|
|
1922
1949
|
super.disconnectedCallback(), this.parentNode === document.body && this.positioning === "body" && this._originalParent && this._originalParent.insertBefore(this, this._originalSibling);
|
|
@@ -2061,6 +2088,7 @@ var Je = class extends W {
|
|
|
2061
2088
|
@pointermove=${this._onPointerMove}
|
|
2062
2089
|
@pointerup=${this._onPointerUp}
|
|
2063
2090
|
@pointercancel=${this._onPointerCancel}
|
|
2091
|
+
@lostpointercapture=${this._onLostPointerCapture}
|
|
2064
2092
|
>
|
|
2065
2093
|
${this.handle ? z`<div class="handle" aria-hidden="true"></div>` : B}
|
|
2066
2094
|
<header part="header">
|
|
Binary file
|
|
Binary file
|