monobill-mintui 0.6.721 → 0.6.723
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/dist/components/off-canvas/OffCanvas.d.ts +1 -9
- package/dist/components/off-canvas/OffCanvas.d.ts.map +1 -1
- package/dist/components/off-canvas/browser.js +20 -88
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +20 -88
- package/dist/index.cjs +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +20 -88
- package/dist/off-canvas.css +1 -1
- package/dist/side-navigation.css +1 -1
- package/package.json +1 -1
|
@@ -15,11 +15,6 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
15
15
|
private _closeButton;
|
|
16
16
|
private _contentObserver;
|
|
17
17
|
private _renderFrame;
|
|
18
|
-
private _exitTimer;
|
|
19
|
-
private _enterPending;
|
|
20
|
-
private _exitPending;
|
|
21
|
-
private _previousFocus;
|
|
22
|
-
private _dialogWasOpen;
|
|
23
18
|
private _dialogKeydownHandler;
|
|
24
19
|
constructor();
|
|
25
20
|
connectedCallback(): void;
|
|
@@ -37,11 +32,8 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
37
32
|
open(): void;
|
|
38
33
|
close(): void;
|
|
39
34
|
render(): void;
|
|
40
|
-
private _getTransformValue;
|
|
41
35
|
private _observeContentMutations;
|
|
42
|
-
private
|
|
43
|
-
private _animateEnter;
|
|
44
|
-
private _animateExit;
|
|
36
|
+
private _syncOpenClasses;
|
|
45
37
|
}
|
|
46
38
|
export default MintOffCanvas;
|
|
47
39
|
//# sourceMappingURL=OffCanvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OffCanvas.d.ts","sourceRoot":"","sources":["../../../src/components/off-canvas/OffCanvas.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,eAAe,CAAA;AACtB,OAAO,gBAAgB,CAAA;AAEvB,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D,cAAM,aAAc,SAAQ,WAAW;IACrC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"OffCanvas.d.ts","sourceRoot":"","sources":["../../../src/components/off-canvas/OffCanvas.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,eAAe,CAAA;AACtB,OAAO,gBAAgB,CAAA;AAEvB,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D,cAAM,aAAc,SAAQ,WAAW;IACrC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,qBAAqB,CAAgD;;IAO7E,iBAAiB,IAAI,IAAI;IAkBzB,oBAAoB,IAAI,IAAI;IAiB5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM9F,OAAO,CAAC,eAAe;IAQvB,KAAK,IAAI,MAAM;IAIf,UAAU,IAAI,MAAM;IAIpB,WAAW,IAAI,iBAAiB;IAQhC,UAAU,IAAI,OAAO;IAKrB,QAAQ,IAAI,MAAM;IAMlB,SAAS,IAAI,MAAM;IAMnB,OAAO,CAAC,kBAAkB;IAS1B,MAAM,IAAI,OAAO;IAKjB,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAyMd,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,gBAAgB;CAQzB;AAOD,eAAe,aAAa,CAAA"}
|
|
@@ -36,29 +36,15 @@ var t = class extends HTMLElement {
|
|
|
36
36
|
];
|
|
37
37
|
}
|
|
38
38
|
constructor() {
|
|
39
|
-
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this.
|
|
39
|
+
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this._dialogKeydownHandler = null;
|
|
40
40
|
}
|
|
41
41
|
connectedCallback() {
|
|
42
|
-
this.classList.add("mint-off-canvas-host"), this.
|
|
43
|
-
|
|
44
|
-
if (e.key === "Escape") {
|
|
45
|
-
e.preventDefault(), e.stopPropagation(), this.close();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (e.key !== "Tab") return;
|
|
49
|
-
let t = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
50
|
-
if (!t) return;
|
|
51
|
-
let n = this._getDialogFocusableElements(t);
|
|
52
|
-
if (!n.length) {
|
|
53
|
-
e.preventDefault(), t.focus();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
let r = n[0], i = n[n.length - 1], a = document.activeElement;
|
|
57
|
-
e.shiftKey && (a === r || !t.contains(a)) ? (e.preventDefault(), i.focus()) : !e.shiftKey && (a === i || !t.contains(a)) && (e.preventDefault(), r.focus());
|
|
42
|
+
this.classList.add("mint-off-canvas-host"), this.style.display = "none", this.render(), this._observeContentMutations(), this._dialogKeydownHandler = (e) => {
|
|
43
|
+
this.isOpen() && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.close());
|
|
58
44
|
}, document.addEventListener("keydown", this._dialogKeydownHandler, !0);
|
|
59
45
|
}
|
|
60
46
|
disconnectedCallback() {
|
|
61
|
-
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this.
|
|
47
|
+
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this._overlay?.remove(), this._offCanvas?.remove();
|
|
62
48
|
}
|
|
63
49
|
attributeChangedCallback(e, t, n) {
|
|
64
50
|
t !== n && this.isConnected && this.render();
|
|
@@ -101,43 +87,29 @@ var t = class extends HTMLElement {
|
|
|
101
87
|
}
|
|
102
88
|
render() {
|
|
103
89
|
let e = this.getId(), t = this.getHeading(), n = this.isOpen(), r = this.getPosition(), i = this.isFullPage(), a = this.getHeight();
|
|
104
|
-
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())
|
|
105
|
-
let o =
|
|
106
|
-
|
|
107
|
-
let s = this.
|
|
108
|
-
|
|
90
|
+
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay mint-off-canvas-hidden", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())), this._offCanvas || (this._offCanvas = document.createElement("div"), this._offCanvas.className = "mint-off-canvas-shell");
|
|
91
|
+
let o = document.body ?? document.documentElement;
|
|
92
|
+
this._overlay.parentElement !== o && o.appendChild(this._overlay), this._offCanvas.parentElement !== o && o.appendChild(this._offCanvas), this._offCanvas.classList.add("mint-off-canvas-shell"), this._offCanvas.dataset.position = r, this._offCanvas.dataset.fullPage = String(i);
|
|
93
|
+
let s = this._offCanvas.querySelector(".mint-off-canvas-panel");
|
|
94
|
+
s || (s = document.createElement("div"), s.className = "mint-off-canvas-panel", this._offCanvas.appendChild(s)), s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "true"), s.hasAttribute("tabindex") || (s.tabIndex = -1), s.style.removeProperty("--off-canvas-width"), s.style.removeProperty("--off-canvas-height"), r === "top" || r === "bottom" ? a && s.style.setProperty("--off-canvas-height", this._normalizeCssValue(a)) : s.style.setProperty("--off-canvas-width", this._normalizeCssValue(this.getWidth())), this._header || (this._header = document.createElement("div"), this._header.className = "mint-off-canvas-header", s.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "mint-off-canvas-heading", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
95
|
+
let c = this._headingSlot.querySelector("mint-text");
|
|
96
|
+
if (t ? (c || (c = document.createElement("mint-text"), c.setAttribute("size", "sub-heading"), c.setAttribute("bold", "true"), this._headingSlot.appendChild(c)), c.textContent = t, c.id = `${e || "mint-off-canvas"}-heading`, s.setAttribute("aria-labelledby", c.id), s.removeAttribute("aria-label")) : c && c.remove(), !t) {
|
|
109
97
|
let e = this.getAttribute("aria-label")?.trim();
|
|
110
|
-
e ?
|
|
98
|
+
e ? s.setAttribute("aria-label", e) : s.hasAttribute("aria-label") || s.setAttribute("aria-label", "Dialog");
|
|
111
99
|
}
|
|
112
100
|
Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._headingSlot && e.getAttribute("slot") === "heading").forEach((e) => {
|
|
113
101
|
this._headingSlot && e.parentElement !== this._headingSlot && this._headingSlot.appendChild(e);
|
|
114
|
-
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"),
|
|
102
|
+
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"), s.appendChild(this._bodySlot)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._bodySlot && e.getAttribute("slot") === "body").forEach((e) => {
|
|
115
103
|
this._bodySlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
116
|
-
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"),
|
|
117
|
-
let
|
|
118
|
-
|
|
104
|
+
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"), s.appendChild(this._actionsSlot));
|
|
105
|
+
let l = this._actionsSlot.querySelector("mint-stack");
|
|
106
|
+
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "mint-off-canvas-actions-stack", this._actionsSlot.appendChild(l)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._actionsSlot && e.getAttribute("slot") === "actions").forEach((e) => {
|
|
119
107
|
Array.from(e.children).forEach((e) => {
|
|
120
|
-
e.parentElement !==
|
|
108
|
+
e.parentElement !== l && l.appendChild(e);
|
|
121
109
|
}), e.parentElement && e.remove();
|
|
122
110
|
}), Array.from(this.children).forEach((e) => {
|
|
123
111
|
e !== this._overlay && e !== this._offCanvas && e.getAttribute("slot") !== "heading" && e.getAttribute("slot") !== "body" && e.getAttribute("slot") !== "actions" && e !== this._headingSlot && e !== this._bodySlot && e !== this._actionsSlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
_getTransformValue(e, t) {
|
|
127
|
-
if (t) switch (e) {
|
|
128
|
-
case "top": return "translateY(0)";
|
|
129
|
-
case "bottom": return "translateY(0)";
|
|
130
|
-
case "left": return "translateX(0)";
|
|
131
|
-
case "right": return "translateX(0)";
|
|
132
|
-
default: return "translateX(0)";
|
|
133
|
-
}
|
|
134
|
-
else switch (e) {
|
|
135
|
-
case "top": return "translateY(-100%)";
|
|
136
|
-
case "bottom": return "translateY(100%)";
|
|
137
|
-
case "left": return "translateX(-100%)";
|
|
138
|
-
case "right": return "translateX(100%)";
|
|
139
|
-
default: return "translateX(100%)";
|
|
140
|
-
}
|
|
112
|
+
}), this._syncOpenClasses(n);
|
|
141
113
|
}
|
|
142
114
|
_observeContentMutations() {
|
|
143
115
|
this._contentObserver ||= new MutationObserver(() => {
|
|
@@ -148,48 +120,8 @@ var t = class extends HTMLElement {
|
|
|
148
120
|
attributeFilter: ["slot"]
|
|
149
121
|
});
|
|
150
122
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (e.closest("[hidden], [aria-hidden=\"true\"]")) return !1;
|
|
154
|
-
let t = window.getComputedStyle(e);
|
|
155
|
-
return t.display !== "none" && t.visibility !== "hidden";
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
_animateEnter() {
|
|
159
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
160
|
-
if (!e || (this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null), this._exitPending = !1, this._enterPending || this.classList.contains("mint-off-canvas-open"))) return;
|
|
161
|
-
this._enterPending = !0;
|
|
162
|
-
let t = this.getPosition(), n = !this._dialogWasOpen;
|
|
163
|
-
if (n) {
|
|
164
|
-
this._dialogWasOpen = !0;
|
|
165
|
-
let e = document.activeElement;
|
|
166
|
-
this._previousFocus = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
167
|
-
}
|
|
168
|
-
e.style.transition = "none", e.style.transform = this._getTransformValue(t, !1), this.style.display = "block", this.classList.remove("mint-off-canvas-hidden"), e.getBoundingClientRect(), e.style.transition = "transform 200ms ease-out", requestAnimationFrame(() => {
|
|
169
|
-
requestAnimationFrame(() => {
|
|
170
|
-
if (!this.isOpen()) {
|
|
171
|
-
this._enterPending = !1;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.classList.add("mint-off-canvas-open"), e.style.transform = this._getTransformValue(t, !0), this._enterPending = !1, n && (this._getDialogFocusableElements(e)[0] ?? e).focus();
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
_animateExit() {
|
|
179
|
-
if (this.classList.contains("mint-off-canvas-hidden") || this._exitPending) return;
|
|
180
|
-
this._enterPending = !1, this._exitPending = !0, this.classList.remove("mint-off-canvas-open");
|
|
181
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
182
|
-
if (!e) {
|
|
183
|
-
this.classList.add("mint-off-canvas-hidden"), this.style.display = "none", this._dialogWasOpen = !1, this._exitPending = !1;
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
let t = this.getPosition();
|
|
187
|
-
e.style.transition = "transform 200ms ease-in", e.style.transform = this._getTransformValue(t, !1), this._exitTimer !== null && clearTimeout(this._exitTimer), this._exitTimer = window.setTimeout(() => {
|
|
188
|
-
if (this._exitTimer = null, this.isOpen()) return;
|
|
189
|
-
this.classList.add("mint-off-canvas-hidden"), this.style.display = "none", e.style.transform = "", e.style.transition = "", this._exitPending = !1;
|
|
190
|
-
let t = this._previousFocus;
|
|
191
|
-
this._previousFocus = null, t?.isConnected && t.focus();
|
|
192
|
-
}, 200);
|
|
123
|
+
_syncOpenClasses(e) {
|
|
124
|
+
!this._offCanvas || !this._overlay || (this._offCanvas.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-hidden", !e));
|
|
193
125
|
}
|
|
194
126
|
};
|
|
195
127
|
customElements.get("mint-off-canvas") || e("mint-off-canvas", t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../chunks/icon-B9P0jyS2.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-CfvRRKGZ.js`),require(`../chunks/button-B4BMYTk1.js`),require(`../chunks/stack-CK2o4-As.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._contentObserver=null,this._renderFrame=null,this.
|
|
1
|
+
require(`../chunks/icon-B9P0jyS2.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-CfvRRKGZ.js`),require(`../chunks/button-B4BMYTk1.js`),require(`../chunks/stack-CK2o4-As.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._contentObserver=null,this._renderFrame=null,this._dialogKeydownHandler=null}connectedCallback(){this.classList.add(`mint-off-canvas-host`),this.style.display=`none`,this.render(),this._observeContentMutations(),this._dialogKeydownHandler=e=>{this.isOpen()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())},document.addEventListener(`keydown`,this._dialogKeydownHandler,!0)}disconnectedCallback(){this._dialogKeydownHandler&&=(document.removeEventListener(`keydown`,this._dialogKeydownHandler,!0),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._overlay?.remove(),this._offCanvas?.remove()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getPosition(){let e=this.getAttribute(`position`)?.toLowerCase();return e===`top`||e===`bottom`||e===`left`||e===`right`?e:`right`}isFullPage(){return this.getAttribute(`full-page`)===`true`}getWidth(){return this.getAttribute(`width`)||`320px`}getHeight(){return this.getAttribute(`height`)||``}_normalizeCssValue(e){return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:e.trim()}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),r=this.getPosition(),i=this.isFullPage(),a=this.getHeight();e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-off-canvas-overlay mint-off-canvas-hidden`,this._overlay.setAttribute(`aria-hidden`,`true`),this._overlay.addEventListener(`click`,()=>this.close())),this._offCanvas||(this._offCanvas=document.createElement(`div`),this._offCanvas.className=`mint-off-canvas-shell`);let o=document.body??document.documentElement;this._overlay.parentElement!==o&&o.appendChild(this._overlay),this._offCanvas.parentElement!==o&&o.appendChild(this._offCanvas),this._offCanvas.classList.add(`mint-off-canvas-shell`),this._offCanvas.dataset.position=r,this._offCanvas.dataset.fullPage=String(i);let s=this._offCanvas.querySelector(`.mint-off-canvas-panel`);s||(s=document.createElement(`div`),s.className=`mint-off-canvas-panel`,this._offCanvas.appendChild(s)),s.setAttribute(`role`,`dialog`),s.setAttribute(`aria-modal`,`true`),s.hasAttribute(`tabindex`)||(s.tabIndex=-1),s.style.removeProperty(`--off-canvas-width`),s.style.removeProperty(`--off-canvas-height`),r===`top`||r===`bottom`?a&&s.style.setProperty(`--off-canvas-height`,this._normalizeCssValue(a)):s.style.setProperty(`--off-canvas-width`,this._normalizeCssValue(this.getWidth())),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-off-canvas-header`,s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-off-canvas-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let c=this._headingSlot.querySelector(`mint-text`);if(t?(c||(c=document.createElement(`mint-text`),c.setAttribute(`size`,`sub-heading`),c.setAttribute(`bold`,`true`),this._headingSlot.appendChild(c)),c.textContent=t,c.id=`${e||`mint-off-canvas`}-heading`,s.setAttribute(`aria-labelledby`,c.id),s.removeAttribute(`aria-label`)):c&&c.remove(),!t){let e=this.getAttribute(`aria-label`)?.trim();e?s.setAttribute(`aria-label`,e):s.hasAttribute(`aria-label`)||s.setAttribute(`aria-label`,`Dialog`)}Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.setAttribute(`variant`,`ghost`),this._closeButton.setAttribute(`icon`,`close`),this._closeButton.setAttribute(`aria-label`,`Close panel`),this._closeButton.addEventListener(`click`,()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._bodySlot.className=`mint-off-canvas-body`,this._bodySlot.setAttribute(`slot`,`body`),s.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`mint-off-canvas-actions`,this._actionsSlot.setAttribute(`slot`,`actions`),s.appendChild(this._actionsSlot));let l=this._actionsSlot.querySelector(`mint-stack`);l||(l=document.createElement(`mint-stack`),l.setAttribute(`direction`,`horizontal`),l.className=`mint-off-canvas-actions-stack`,this._actionsSlot.appendChild(l)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==l&&l.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._offCanvas&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._syncOpenClasses(n)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_syncOpenClasses(e){!this._offCanvas||!this._overlay||(this._offCanvas.classList.toggle(`mint-off-canvas-open`,e),this._overlay.classList.toggle(`mint-off-canvas-open`,e),this._overlay.classList.toggle(`mint-off-canvas-hidden`,!e))}};customElements.get(`mint-off-canvas`)||e.t(`mint-off-canvas`,t),module.exports=t;
|
|
@@ -24,29 +24,15 @@ var t = class extends HTMLElement {
|
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
26
|
constructor() {
|
|
27
|
-
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this.
|
|
27
|
+
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this._dialogKeydownHandler = null;
|
|
28
28
|
}
|
|
29
29
|
connectedCallback() {
|
|
30
|
-
this.classList.add("mint-off-canvas-host"), this.
|
|
31
|
-
|
|
32
|
-
if (e.key === "Escape") {
|
|
33
|
-
e.preventDefault(), e.stopPropagation(), this.close();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (e.key !== "Tab") return;
|
|
37
|
-
let t = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
38
|
-
if (!t) return;
|
|
39
|
-
let n = this._getDialogFocusableElements(t);
|
|
40
|
-
if (!n.length) {
|
|
41
|
-
e.preventDefault(), t.focus();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let r = n[0], i = n[n.length - 1], a = document.activeElement;
|
|
45
|
-
e.shiftKey && (a === r || !t.contains(a)) ? (e.preventDefault(), i.focus()) : !e.shiftKey && (a === i || !t.contains(a)) && (e.preventDefault(), r.focus());
|
|
30
|
+
this.classList.add("mint-off-canvas-host"), this.style.display = "none", this.render(), this._observeContentMutations(), this._dialogKeydownHandler = (e) => {
|
|
31
|
+
this.isOpen() && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.close());
|
|
46
32
|
}, document.addEventListener("keydown", this._dialogKeydownHandler, !0);
|
|
47
33
|
}
|
|
48
34
|
disconnectedCallback() {
|
|
49
|
-
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this.
|
|
35
|
+
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this._overlay?.remove(), this._offCanvas?.remove();
|
|
50
36
|
}
|
|
51
37
|
attributeChangedCallback(e, t, n) {
|
|
52
38
|
t !== n && this.isConnected && this.render();
|
|
@@ -89,43 +75,29 @@ var t = class extends HTMLElement {
|
|
|
89
75
|
}
|
|
90
76
|
render() {
|
|
91
77
|
let e = this.getId(), t = this.getHeading(), n = this.isOpen(), r = this.getPosition(), i = this.isFullPage(), a = this.getHeight();
|
|
92
|
-
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())
|
|
93
|
-
let o =
|
|
94
|
-
|
|
95
|
-
let s = this.
|
|
96
|
-
|
|
78
|
+
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay mint-off-canvas-hidden", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())), this._offCanvas || (this._offCanvas = document.createElement("div"), this._offCanvas.className = "mint-off-canvas-shell");
|
|
79
|
+
let o = document.body ?? document.documentElement;
|
|
80
|
+
this._overlay.parentElement !== o && o.appendChild(this._overlay), this._offCanvas.parentElement !== o && o.appendChild(this._offCanvas), this._offCanvas.classList.add("mint-off-canvas-shell"), this._offCanvas.dataset.position = r, this._offCanvas.dataset.fullPage = String(i);
|
|
81
|
+
let s = this._offCanvas.querySelector(".mint-off-canvas-panel");
|
|
82
|
+
s || (s = document.createElement("div"), s.className = "mint-off-canvas-panel", this._offCanvas.appendChild(s)), s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "true"), s.hasAttribute("tabindex") || (s.tabIndex = -1), s.style.removeProperty("--off-canvas-width"), s.style.removeProperty("--off-canvas-height"), r === "top" || r === "bottom" ? a && s.style.setProperty("--off-canvas-height", this._normalizeCssValue(a)) : s.style.setProperty("--off-canvas-width", this._normalizeCssValue(this.getWidth())), this._header || (this._header = document.createElement("div"), this._header.className = "mint-off-canvas-header", s.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "mint-off-canvas-heading", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
83
|
+
let c = this._headingSlot.querySelector("mint-text");
|
|
84
|
+
if (t ? (c || (c = document.createElement("mint-text"), c.setAttribute("size", "sub-heading"), c.setAttribute("bold", "true"), this._headingSlot.appendChild(c)), c.textContent = t, c.id = `${e || "mint-off-canvas"}-heading`, s.setAttribute("aria-labelledby", c.id), s.removeAttribute("aria-label")) : c && c.remove(), !t) {
|
|
97
85
|
let e = this.getAttribute("aria-label")?.trim();
|
|
98
|
-
e ?
|
|
86
|
+
e ? s.setAttribute("aria-label", e) : s.hasAttribute("aria-label") || s.setAttribute("aria-label", "Dialog");
|
|
99
87
|
}
|
|
100
88
|
Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._headingSlot && e.getAttribute("slot") === "heading").forEach((e) => {
|
|
101
89
|
this._headingSlot && e.parentElement !== this._headingSlot && this._headingSlot.appendChild(e);
|
|
102
|
-
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"),
|
|
90
|
+
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"), s.appendChild(this._bodySlot)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._bodySlot && e.getAttribute("slot") === "body").forEach((e) => {
|
|
103
91
|
this._bodySlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
104
|
-
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"),
|
|
105
|
-
let
|
|
106
|
-
|
|
92
|
+
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"), s.appendChild(this._actionsSlot));
|
|
93
|
+
let l = this._actionsSlot.querySelector("mint-stack");
|
|
94
|
+
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "mint-off-canvas-actions-stack", this._actionsSlot.appendChild(l)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._actionsSlot && e.getAttribute("slot") === "actions").forEach((e) => {
|
|
107
95
|
Array.from(e.children).forEach((e) => {
|
|
108
|
-
e.parentElement !==
|
|
96
|
+
e.parentElement !== l && l.appendChild(e);
|
|
109
97
|
}), e.parentElement && e.remove();
|
|
110
98
|
}), Array.from(this.children).forEach((e) => {
|
|
111
99
|
e !== this._overlay && e !== this._offCanvas && e.getAttribute("slot") !== "heading" && e.getAttribute("slot") !== "body" && e.getAttribute("slot") !== "actions" && e !== this._headingSlot && e !== this._bodySlot && e !== this._actionsSlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
_getTransformValue(e, t) {
|
|
115
|
-
if (t) switch (e) {
|
|
116
|
-
case "top": return "translateY(0)";
|
|
117
|
-
case "bottom": return "translateY(0)";
|
|
118
|
-
case "left": return "translateX(0)";
|
|
119
|
-
case "right": return "translateX(0)";
|
|
120
|
-
default: return "translateX(0)";
|
|
121
|
-
}
|
|
122
|
-
else switch (e) {
|
|
123
|
-
case "top": return "translateY(-100%)";
|
|
124
|
-
case "bottom": return "translateY(100%)";
|
|
125
|
-
case "left": return "translateX(-100%)";
|
|
126
|
-
case "right": return "translateX(100%)";
|
|
127
|
-
default: return "translateX(100%)";
|
|
128
|
-
}
|
|
100
|
+
}), this._syncOpenClasses(n);
|
|
129
101
|
}
|
|
130
102
|
_observeContentMutations() {
|
|
131
103
|
this._contentObserver ||= new MutationObserver(() => {
|
|
@@ -136,48 +108,8 @@ var t = class extends HTMLElement {
|
|
|
136
108
|
attributeFilter: ["slot"]
|
|
137
109
|
});
|
|
138
110
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (e.closest("[hidden], [aria-hidden=\"true\"]")) return !1;
|
|
142
|
-
let t = window.getComputedStyle(e);
|
|
143
|
-
return t.display !== "none" && t.visibility !== "hidden";
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
_animateEnter() {
|
|
147
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
148
|
-
if (!e || (this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null), this._exitPending = !1, this._enterPending || this.classList.contains("mint-off-canvas-open"))) return;
|
|
149
|
-
this._enterPending = !0;
|
|
150
|
-
let t = this.getPosition(), n = !this._dialogWasOpen;
|
|
151
|
-
if (n) {
|
|
152
|
-
this._dialogWasOpen = !0;
|
|
153
|
-
let e = document.activeElement;
|
|
154
|
-
this._previousFocus = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
155
|
-
}
|
|
156
|
-
e.style.transition = "none", e.style.transform = this._getTransformValue(t, !1), this.style.display = "block", this.classList.remove("mint-off-canvas-hidden"), e.getBoundingClientRect(), e.style.transition = "transform 200ms ease-out", requestAnimationFrame(() => {
|
|
157
|
-
requestAnimationFrame(() => {
|
|
158
|
-
if (!this.isOpen()) {
|
|
159
|
-
this._enterPending = !1;
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this.classList.add("mint-off-canvas-open"), e.style.transform = this._getTransformValue(t, !0), this._enterPending = !1, n && (this._getDialogFocusableElements(e)[0] ?? e).focus();
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
_animateExit() {
|
|
167
|
-
if (this.classList.contains("mint-off-canvas-hidden") || this._exitPending) return;
|
|
168
|
-
this._enterPending = !1, this._exitPending = !0, this.classList.remove("mint-off-canvas-open");
|
|
169
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
170
|
-
if (!e) {
|
|
171
|
-
this.classList.add("mint-off-canvas-hidden"), this.style.display = "none", this._dialogWasOpen = !1, this._exitPending = !1;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let t = this.getPosition();
|
|
175
|
-
e.style.transition = "transform 200ms ease-in", e.style.transform = this._getTransformValue(t, !1), this._exitTimer !== null && clearTimeout(this._exitTimer), this._exitTimer = window.setTimeout(() => {
|
|
176
|
-
if (this._exitTimer = null, this.isOpen()) return;
|
|
177
|
-
this.classList.add("mint-off-canvas-hidden"), this.style.display = "none", e.style.transform = "", e.style.transition = "", this._exitPending = !1;
|
|
178
|
-
let t = this._previousFocus;
|
|
179
|
-
this._previousFocus = null, t?.isConnected && t.focus();
|
|
180
|
-
}, 200);
|
|
111
|
+
_syncOpenClasses(e) {
|
|
112
|
+
!this._offCanvas || !this._overlay || (this._offCanvas.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-hidden", !e));
|
|
181
113
|
}
|
|
182
114
|
};
|
|
183
115
|
customElements.get("mint-off-canvas") || e("mint-off-canvas", t);
|